Javascript Regular Expression Replacement Function

If I have the following line:

var str = "Test.aspx?ID=11&clicked=false+5+3";
str = str.replace(????????, 'true');

How to replace the substring "false + 5 + 3" with "true" using REGEX?

Thanks in advance!

+5
source share
3 answers
str = str.replace(/clicked=[^&]*/, 'clicked=true');

this will replace anything in the clicked parameter, not just false + ...

+3
source
str = str.replace(/false\+5\+3/, 'true');

You need to exit +, as it means something special in the regular expression.

+4
source
var str = "Test.aspx?ID=11&clicked=false+5+3";
str = str.replace(/false[+]5[+]3/, 'true');
0
source

All Articles