MJ
asked on
How to replace a token in a string with square brackets?
I'm trying to replace the token "[RANDOMNUMBER]" in a string but my code is not working? I've tried single and double backslashes and it hasn't worked?
sample string: //ad.amgdgt.com/ads/?t=ap& px=79079&r nd=[RANDOMNUMBER]
function detokenizeTags(imgSrc){
var rn = Math.random() + "",
rnd = rn * 10000000000000;
imgSrc.replace(/\[RANDOMNUMBER\]/g,rnd);
return imgSrc;
}
sample string: //ad.amgdgt.com/ads/?t=ap&
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER