In PHP using preg_match I want to match one of many multicharacter strings (e.g. "date", "after" and "latest") (followed by some more match, which are saved e.g. ([0-9]+) and the like ).
If it were a single characters (e.g. b, f and g) the regexp would just be:
/[bfg] rest of the regex(p)?/
If I were to match (and save) the match of multicharacter开发者_JAVA技巧 strings it would be something like:
/(date|after|latest) rest of the regex(p)?/
Now can I match "date", "after" or "latest" without saving whichever one was matched in the resulting array?
Use non capture group:
/(?:date|after|latest) rest of the regex(p)?/
精彩评论