Reputation: 493
If I have the following string:
var str = "Test.aspx?ID=11&clicked=false+5+3";
str = str.replace(????????, 'true');
How can I replace the substring "false+5+3" with "true" using REGEX?
Thanks in advance!!!
Upvotes: 5
Views: 666
Reputation: 9030
str = str.replace(/clicked=[^&]*/, 'clicked=true');
this will replace anything in clicked parameter, not only false+...
Upvotes: 3
Reputation: 11042
var str = "Test.aspx?ID=11&clicked=false+5+3";
str = str.replace(/false[+]5[+]3/, 'true');
Upvotes: 0
Reputation: 36476
str = str.replace(/false\+5\+3/, 'true');
You need to escape the +
since it means something special in regex.
Upvotes: 4