简单的问题:
c#、.net 中单词字符 \w
的模式是什么?
我的第一个想法是它匹配 [A-Za-z0-9_]
和 documentation告诉我:
Character class Description Pattern Matches \w Matches any \w "I", "D", "A", "1", "3" word character. in "ID A1.3"
这不是很有帮助。
\w
似乎也匹配 äöü
。还有什么?是否有更好(准确)的定义可用?
最佳答案
来自documentation :
Word Character: \w
\w
matches any word character. A word character is a member of any of the Unicode categories listed in the following table.
Ll
(Letter, Lowercase)Lu
(Letter, Uppercase)Lt
(Letter, Titlecase)Lo
(Letter, Other)Lm
(Letter, Modifier)Nd
(Number, Decimal Digit)Pc
(Punctuation, Connector)
- This category includes ten characters, the most commonly used of which is the LOWLINE character (_), u+005F.
If ECMAScript-compliant behavior is specified,
\w
is equivalent to[a-zA-Z_0-9]
.
另见
关于c# - .Net 正则表达式 : what is the word character\w?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2998519/