What does the regex string "\\p{Cntrl}" match in Java?

From the documentation of Pattern:

\p{Cntrl} A control character: [\x00-\x1F\x7F]

That is, it matches any character with hexadecimal value 00 through 1F or 7F.

The Wikipedia article on control characters lists each character and what it's used for if you're interested.


\p{name} matches a Unicode character class; consult the appropriate Unicode spec to see what code points are in the class. Here is a discussion specific to the Java regex engine (Cntrl being one of the examples Any ASCII control character in the range 0-127. This effectively means characters 0-31 and 127.), although the same thing applies to many other regex engines.

Tags:

Java

Regex