Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
此正则表达式检查字符串是否包含一个单词,但它读取带有 ' 和 "" 两个单词之类的符号的单词.. 如何允许此正则表达式使用符号?
WordCount = New Regex("\w+").Matches(line).Count
如果只有一个符号,例如“不要”或“女孩” ,您可以尝试
\w+['"]?\w*
这意味着,单词必须以字符开头,可以以'或"结尾