What does this pattern '/\\\(?!&#|\?#)/' match in PHP preg_replace function?
Is this pattern valid?
Why there are 3 backslashes in a row \\\?
The pattern checks for a literal backslash not followed by &# or ?#.
Yes.
Because it's written as a PHP string literal. '\\' (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 \?#.