gpt4 book ai didi

c# - .Net 正则表达式 : what is the word character\w?

转载 作者:IT王子 更新时间:2023-10-29 03:42:29 26 4
gpt4 key购买 nike

简单的问题:
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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com