JavaScript replacement string of characters

 

When replace characters in the replacement string is the use of javascript, found only replace the first character matches, the latter are not replaced.

 

"Aaaaaa" .replace ( "a", "b"); the returned string is baaaaa

Should be written

"aaaaaa".replace(/a/g,"b"); 

Guess you like

Origin www.cnblogs.com/dch0/p/12103779.html