且构网

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

RegExp带有特殊字符(。)javascript的单词边界

更新时间:2023-09-04 09:43:34

您可以先检查单词边界(当你正在做的事情,但由于,棘手的部分是在最后你不能使用单词边界。但是,您可以在最后检查空格字符:

You can check for the word boundary first (as you were doing), but the tricky part is at the end where you can't use the word boundary because of the .. However, you can check for a whitespace character at the end instead:

/\b(u\.s\.a\.)(?:\s|$)/gi

查看 Regex101