- What does this pattern
'/\\\(?!&#|\?#)/'match in PHP preg_replace function? - Is this pattern valid?
- Why there are 3 backslashes in a row
\\\?
What does this pattern ‘/\\\(?!&#|\?#)/’ match in PHP preg_replace function? Is this pattern valid?
Share
&#or?#.'\\'(an escaped escape character) in a string literal resolves to the actual string'\', so the actual regular expression is/\\(?!&#|\?#)/. The backslash is escaped inside the regex so it does not escape the(. So the actual pattern looked for is\&#or\?#.