Replace only whole word in javascript [duplicate]
Possible Duplicate:
Match and replace whole words in javascript
I want to replace in JavaScript the word "microsoft" with "stackoverflow".
But I only want it to replace the whole word - so I don't want "microsoft microsftttt" 开发者_Python百科to be turned into "stackoverflow stackoverflowttt".
You can add ' '
to begin of string & end of string, replace ' microsoft '
to ' stackoverflow '
and cut ' '
, added before it
精彩评论