What is the {L} Unicode category?

一世执手 提交于 2019-12-17 09:48:09

问题


I came across some regular expressions that contain [^\\p{L}]. I understand that this is using some form of a Unicode category, but when I checked the documentation, I found only the following "L" categories:

Lu  Uppercase letter    UPPERCASE_LETTER
Ll  Lowercase letter    LOWERCASE_LETTER
Lt  Titlecase letter    TITLECASE_LETTER
Lm  Modifier letter     MODIFIER_LETTER
Lo  Other letter        OTHER_LETTER

What is L in this context?


回答1:


Taken from this link: http://www.regular-expressions.info/unicode.html

Check the Unicode Character Properties section.

\p{L} matches a single code point in the category "letter". If your input string is à encoded as U+0061 U+0300, it matches a without the accent. If the input is à encoded as U+00E0, it matches à with the accent. The reason is that both the code points U+0061 (a) and U+00E0 (à) are in the category "letter", while U+0300 is in the category "mark".




回答2:


I don't see any explicit mention of it, but an example on this page indicates that \\p{L} means any letter:

Categories may be specified with the optional prefix Is: Both \p{L} and \p{IsL} denote the category of Unicode letters.



来源:https://stackoverflow.com/questions/5969440/what-is-the-l-unicode-category

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!