简体   繁体   中英

What built-in regex character classes are supported Java

...when used in patterns like "\\\\p{someCharacterClass}" .
I've used/seen some:

  • Lower
  • Upper
  • InCombiningDiacriticalMarks
  • ASCII

What is the definitive list of all supported built-in character classed? Where is it documented? What are the exact meanings?

Edited...

There seem to be a lot of "RTFM" answers refering to the javadoc for Pattern . That's the first place I looked before asking this question. Just so everyone is clear, the javadoc for Pattern makes no mention of any of the classes listed above.

The "correct" answer will mention "InCombiningDiacriticalMarks" somewhere on the page, and will not be some vague reference to "Unicode Standards".

The documentation for Pattern says in the "Unicode Support" section:

The supported categories are those of The Unicode Standard in the version specified by the Character class. The category names are those defined in the Standard, both normative and informative. The block names supported by Pattern are the valid block names accepted and defined by UnicodeBlock.forName .

The documentation for UnicodeBlock.forName states:

Block names are determined by The Unicode Standard.

On http://unicode.org there is the FAQ Where can I find the definitive list of Unicode blocks? :

A: The Unicode blocks and their names are a normative part of the Unicode Standard. The exact list is always maintained in one of the files of the Unicode Character Database , Blocks.txt .

Finally, in Blocks.txt there is the line:

0300..036F; Combining Diacritical Marks

These characters can be found in the Combining Diacritical Marks code chart (from Unicode 6.0 Character Code Charts ).

Pattern API says to adhere to regular expression level 1 as defined by http://www.unicode.org/reports/tr18/

There are three nice tables (search UCD.html), and look at UCD.html itself.

This page has some good details for a few popular classes like:

  • \\p{L} or \\p{Letter} : any kind of letter from any language.
  • \\p{M} or \\p{Mark} : a character intended to be combined with another character (eg accents, umlauts, enclosing boxes, etc.).
  • \\p{N} or \\p{Number} : any kind of numeric character in any script.

The spec is http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html . In some cases, it refers to TUS for a particular version, you can find that material at http://unicode.org .

查看Pattern类的javadocs。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM