【发布时间】:2021-02-12 14:38:48
【问题描述】:
我正在尝试使用 RegExp 替换一组特定的字符串,但它没有替换。我正在尝试的正则表达式是
\@223(?:\D|'')\gm
要测试的字符串集是这些
@223 ->Replace 223 with #
@223+@33 ->Replace 223 with #
@22; ->Not Replace
@2234 ->Not Replace
@22234 ->Not Replace
@223@44 ->Replace 223 with #
【问题讨论】:
-
如果它以
@223开头,您是否将其更改为223 with #? -
你想用
#替换233吗? -
只要使用
str = str.replace(/@223\b/, "#")
标签: javascript regex string replace regexp-replace