Problem with javascript replace function that replaces only first occurence
by Taavi Rammar

By default, javascript default replace function is only replacing first occurrence in the string. If you want to change them all, add /g regexp param:
mystring='yes, yes, yes';
alert(mystring.replace('yes', 'no')) // outputs 'no, yes, yes'
alert(mystring.replace(/yes/g, 'no'));// outputs 'no, no, no'

That's it. Enjoy.

Copyright by techTips