The redirect documentation explains the PCRE regex rule syntax with the following examples:
^https://reddit.com|https://old.reddit.com
^https://docs.rs/([^/]+)/(?:[^/]+)/(.*)|https://docs.rs/$1/latest/$2
^(https?:\/\/|)([^\?]*).*$|$1$2?=
However, as far as I understand regex, only the last is valid and therefore the examples should be:
^https:\/\/reddit\.com!https://old.reddit.com
^https:\/\/docs\.rs\/([^\/]+)\/(?:[^\/]+)\/(.*)|https://docs.rs/$1/latest/$2
^(https?:\/\/|)([^\?]*).*$|$1$2?=
regex101 throws up errors if I use the example rules verbatim otherwise. My guess is that there’s some preprocessing occurring before the regex is executed so that rules defined by users can be a bit more relaxed for simpler scenarios such as old Reddit, with the preprocessing adding the extra character escaping as necessary. Is this correct?
It would be great to get some clarification in the documentation to better understand when we should consider escaping characters so that they don’t get confused as regex tokens.