Reputation: 196
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.
Upvotes: 1
Views: 116
Reputation: 101604
(?<!PATTERN)
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.
Upvotes: 1
Reputation: 27017
This means, "Find a u
that is not preceded by \\
." The ?<!
construct is the negative lookbehind, and the \\
is an escaped \
.
Upvotes: 4