且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

正则表达式匹配整个单词

更新时间:2022-01-07 21:47:30

您似乎只想在被替换的字符串周围只有空格或行首/行尾.

You seem to want to have only white spaces or begin/end of line around your replaced string.

使用诸如(^|\s)string 之类的东西来替换(\s|$).不确定您使用的是什么语言,您可能需要稍微调整此字符串.

Use somehting like (^|\s)string to replace(\s|$). Not sure what language you are using you may need to tune this string a little bit.