How to match the entire alphabet, except for a few?

I want to combine [az] only with the exception of the letters a,e,i,o,u

Using a negative set [^aeiou]* I could match everything except a,e,i,o,u , but how to limit my everything to [az] ?

This can be easily done using character class subtraction ( [az-[aeiou]] ) in XML Schema, XPath, .NET (2.0+) and JGsoft-regex, but how to do it in PCRE?

+6
source share
1 answer

You can use a negative statement. It's like a kind of subtraction.

 (?![aeiou])[az] ^ ^ | | subtract from 

Demo

+9
source

Source: https://habr.com/ru/post/985924/


All Articles