javaregexposix-erecharacter-properties

POSIX character equivalents in Java regular expressions


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?


Solution

  • 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}