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

标签 c# .net regex

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

相关文章:

c# - 如何通过我的 Web 服务运行 .exe 文件?

.net - NuGet:是否需要引用隐式依赖项?

Java正则表达式替换一个接一个的单词

jquery - 如何使用 DataTables jQuery 插件和正则表达式进行短语过滤?

c# - LinQtoExcel 使用 asp 文件上传

c# - 定义用于执行程序的工作目录 (C#)

c# - C# 静态方法模板

c# - 在 C# 中使用 'ref' 关键字

c# - 将 C 结构编码为 C# 委托(delegate)的返回值

regex - 从 netstat 命令中提取端口号