开发者

Replace only whole word in javascript [duplicate]

开发者 https://www.devze.com 2023-03-21 02:07 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: Match and replace whole words in javascript
This question already has an answer here: Closed 11 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消