Sunday, 15 April 2012

javascript - .replace all variables in string -



javascript - .replace all variables in string -

this question has reply here:

replacing occurrences of string in javascript 29 answers

i want replace words match variable in string, doesn't work. utilize code:

var findstr = "hello hi, test, hi"; var textsearch = "hi"; findstr = findstr.replace(textsearch,'<span>'+textsearch+'</span>');

it has alter color of hi first hi changes, sec 1 doesn't.

the replace method you're looking for.

for example: somestring.replace("string want replace", "with string")

javascript string replace

No comments:

Post a Comment