replacing strings with regex in javascript
Posted
by koko
on Stack Overflow
See other posts from Stack Overflow
or by koko
Published on 2010-05-10T10:42:01Z
Indexed on
2010/05/10
10:44 UTC
Read the original article
Hit count: 413
Hi,
regex is bugging me right now. I simply want to replace the range=100 in a string like
var string = '...commonstringblabla&range=100&stringandsoon...';
with
...commonstringblabla&range=400&stringandsoon...
I successfully matched the "range=100"-part with
alert( string.match(/range=100/) );
But when I try to replace it
string.replace(/range=100/, 'range=400');
nothing happens, the string still has the range=100 in it... I don't get it, please help.
© Stack Overflow or respective owner