解释正则表达式
I need help interpreting the meaning of a regular expression. I'm trying to understand to improve my skills with them...
The regular expression is:
`(?<!\\\\)u`
It is used in PHP with preg_replace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着“查找前面没有
\\
的u
”。? 构造是 负向后查找,并且
\\
是转义的\
。This means, "Find a
u
that is not preceded by\\
." The?<!
construct is the negative lookbehind, and the\\
is an escaped\
.是负向后查找,其中 PATTERN 不得在组后面的匹配之前找到,在本例中为
\\
。 (我还基于 4\
的使用,因为在 php 字符串中需要转义)另请参阅 这个演示是一个实例。
is a negative look-behind, where PATTERN must not be found before the match following the group, which is a
\\
in this case. (I'm also going on the basis the the 4\
is used due to escaping necessary within a php string)See also this demo for a live example.