I am facing an issue where i need to replace all the character in string.
replace function will not work. it will replace only the first value and the rest of remain same so you need to use RegExp.
use this sample code to repalce all "#####" with "'"
var myval="Sums#####ka Oblast#####tests#####sunny#####abcs#####oks#####"
var regex1 = new RegExp('#####', 'g')
myval = myval.replace(regex1,"'");
alert(myval)
Refernce :
http://stackoverflow.com/questions/22145822/javascript-replace-all-comma-in-a-string
new RegExp('#####', 'g') // g means perform a global match (find all matches rather than stopping after the first match
replace function will not work. it will replace only the first value and the rest of remain same so you need to use RegExp.
use this sample code to repalce all "#####" with "'"
var myval="Sums#####ka Oblast#####tests#####sunny#####abcs#####oks#####"
var regex1 = new RegExp('#####', 'g')
myval = myval.replace(regex1,"'");
alert(myval)
Refernce :
http://stackoverflow.com/questions/22145822/javascript-replace-all-comma-in-a-string
new RegExp('#####', 'g') // g means perform a global match (find all matches rather than stopping after the first match
No comments:
Post a Comment