UPDATE: I’m making progress, but this is hard!
The test text will be valid[REGEX_EMAIL|REGEX_PASSWORD|REGEX_TEST].
(The real life text is required|valid[REGEX_EMAIL]|confirmed[emailconfirmation]|correct[not in|emailconfirmation|email confirmation].)
([^|]+) saves REGEX_EMAIL, REGEX_PASSWORD and REGEX_TEST in an array.
^[^[]+\[ matches valid[
\] matches ]
^[^[]+\[ + ([^|]+) + \] doesn’t save REGEX_EMAIL, REGEX_PASSWORD and REGEX_TEST in an array.
How to solve?
Why is it important to try to everything with a single regular expression? It becomes much easier if you extract the two parts first and then split the strings on
|using explode:Output: