character-class

Regular expression \p{L} and \p{N}

自古美人都是妖i 提交于 2019-11-26 09:06:58
问题 I am new to regular expressions and have been given the following regular expression: (\\p{L}|\\p{N}|_|-|\\.)* I know what * means and | means \"or\" and that \\ escapes. But what I don\'t know what \\p{L} and \\p{N} means. I have searched Google for it, without result... Can someone help me? 回答1: \p{L} matches a single code point in the category "letter". \p{N} matches any kind of numeric character in any script. Source: regular-expressions.info If you're going to work with regular

Exclude characters from a character class

两盒软妹~` 提交于 2019-11-26 06:47:06
问题 Is there a simple way to match all characters in a class except a certain set of them? For example if in a lanaguage where I can use \\w to match the set of all unicode word characters, is there a way to just exclude a character like an underscore \"_\" from that match? Only idea that came to mind was to use negative lookahead/behind around each character but that seems more complex than necessary when I effectively just want to match a character against a positive match AND negative match.