POSIX character equivalents in Java regular expressions

Stephan picture Stephan · Jul 7, 2011 · Viewed 7.5k times · Source

I would like to use a regular expression like this in Java : [[=a=][=e=][=i=]].

But Java doesn't support the POSIX classes [=a=], [=e=] etc.

How can I do this? More precisely, is there a way to not use US-ASCII?

Answer

Johan Sjöberg picture Johan Sjöberg · Jul 7, 2011

Java does support posix character classes. The syntax is just different, for instance:

\p{Lower}
\p{Upper}
\p{ASCII}
\p{Alpha}
\p{Digit}
\p{Alnum}
\p{Punct}
\p{Graph}
\p{Print}
\p{Blank}
\p{Cntrl}
\p{XDigit}
\p{Space}