What is the {L} Unicode category?

前端 未结 2 990
挽巷
挽巷 2020-12-01 16:32

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 documen

相关标签:
2条回答
  • 2020-12-01 17:12

    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".

    0 讨论(0)
  • 2020-12-01 17:15

    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.

    0 讨论(0)
提交回复
热议问题