POSIX character classes

Java already has support for POSIX character classes using the \p operator. RegExPlus adds support for them using the [:class:] POSIX bracket expressions.

Syntax

Tutorials

\p{class}

Java already has support for POSIX character classes via the \p operator.

As an example, 0x\p{XDigit}++ will match a hex number, for example, 0xFF.

In the Pattern class api is a list of the supported class names along with a list of the characters that they match.

[:class:]

RegExPlus adds support for POSIX classes in the form [:class:]. This is the same form support by PCRE and Ruby.

As an example, 0x[[:xdigit:]]++ will match a hex number, for example, 0xFF.

In the Pattern class api is a list of the supported class names along with a list of the characters that they match.

[:class:] outside of a character class

Note that unlike the \p{class} syntax, the [:class:] syntax is only allowed within a character class. If used outside a character class, a PatternSyntaxException will be thrown.

For example, if you accidently forget to put the expression in a character class, 0x[:xdigit:]++, an exception will be thrown. See the results on JavaStar.