What does the regex string "\\p{Cntrl}" match in Java?
I think it's matching all control characters (not sure what "all" might be) but I can't be certain, nor can I find it in any documentation other than some mus开发者_JS百科ings in a Perl forum. Does anyone know?
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.
精彩评论