Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript regex replace function

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!!!

like image 266
Sash Avatar asked Aug 09 '11 14:08

Sash


1 Answers

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

You need to escape the + since it means something special in regex.

like image 174
tskuzzy Avatar answered Sep 18 '22 01:09

tskuzzy