How to match all alphabet except few?

只谈情不闲聊 提交于 2019-12-30 06:11:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!