replace all occurences of a string in variable javascript

by Ramshan 2014-10-18 17:43:00

to replace all the occurence of a string, just use javascript replace function as,

strname.replace(/rep/g, 'with');

if you want to replace all the occurences of a string in a variable use javascript REGEX concetp,
strname.replace(new RegExp(repVar,"g"), repwith)
1462
like
0
dislike
0
mail
flag

You must LOGIN to add comments