问题
I want to match [a-z] only except the letters a,e,i,o,u
Using negated set [^aeiou]* I could match everything except a,e,i,o,u, but how to restrict my everything to [a-z]?
This can be easily done using character class subtraction ([a-z-[aeiou]]) in XML Schema, XPath, .NET (2.0+), and JGsoft regex flavors, but how can I do it in PCRE?
回答1:
You could use negative lookahead assertion. It's like a kind of subtraction.
(?![aeiou])[a-z]
^ ^
| |
subtract from
DEMO
来源:https://stackoverflow.com/questions/29859968/how-to-match-all-alphabet-except-few