js replace string function

 

 

 

 

Indeed, the PHP function is strreplace (there are many functions for replacements).The "g" flag indicates that the regular expression should be tested against all possible matches in a string. Without the g flag, itll only test for the first. I use replace() on that string to "feed" the matched color codes to a function returning HTML - kind of a parameterized string.Javascript: Replace x only if its the first word in a text, not elsewhere. Im working on a simple JS code to replace some words with others in a text using an array.