查找 pec+ 的正则表达式模式
Regex pattern to find pec+
我正在尝试匹配短语
中的"word" pec+
I cannot find pec+
我试过模式 \bpec\+\b
,但没有匹配项。
因为+
不是单词字符,需要通过匹配非单词边界来结束表达式,使用\B
:
\bpec\+\B
查看 live demo,显示
的匹配项
foo pec+ bar
但不适用于以下任何一项:
foopec+ bar
foo pec+bar
foopec+bar
A word boundary ( \b ) is defined as a spot between two characters that has
a \w on one side of it and and a \W on the other side of it (in either order),
counting the imaginary characters off the beginning and end of the string as
matching a \W .
@ and + being non word chars, there is no \w char to match.
我正在尝试匹配短语
中的"word"pec+
I cannot find pec+
我试过模式 \bpec\+\b
,但没有匹配项。
因为+
不是单词字符,需要通过匹配非单词边界来结束表达式,使用\B
:
\bpec\+\B
查看 live demo,显示
的匹配项foo pec+ bar
但不适用于以下任何一项:
foopec+ bar
foo pec+bar
foopec+bar
A word boundary ( \b ) is defined as a spot between two characters that has a \w on one side of it and and a \W on the other side of it (in either order), counting the imaginary characters off the beginning and end of the string as matching a \W .
@ and + being non word chars, there is no \w char to match.