I have a list of regular expressions:
suresnes|suresne|surenes|surene pommier|pommiers ^musique$ ^(faq|aide)$ ^(file )?loss( )?less$ paris faq <<< this match twice
My use case is that every template that got a match displays a link to my user, so I can have multiple pattern matches.
I am testing tag templates against a simple line of text "live in paris" / "faq" / "pom" ...
An easy way to do this is to iterate over all the templates using preg_match , but I will do it on a page with high performance criticality , so this view is bad for me .
Here's what I tried: combining all thoses expressions into one with group names:
preg_match("@(?P<group1>^(faq|aide|todo|paris)$)|(?P<group2>(paris)$)@im", "paris", $groups);
As you can see, each pattern is grouped: (?P<GROUPNAME>PATTERN) , and they are all separated by a pipe | .
The result is not what I expect, since only the first group match is returned. See when a match occurs, parsing is stopped.
What I want is a list of all suitable groups. preg_match_all does not help either.
Thanks!
source share