我在我的 c# 代码中使用以下内容
MatchCollection matches = Regex.Matches(input, @"\b[\w]*\b");
我需要启用正则表达式以允许 # 或 + 字符,因为它试图在输入字符串中查找编程语言。因此 C# 或 C++ 被忽略。
我试过了
MatchCollection matches = Regex.Matches(input, @"\b[\w+\$\#\+']*\b");
MatchCollection matches = Regex.Matches(input, @"\b[a-zA-Z0-9@#$%&*+\-]*\b");
MatchCollection matches = Regex.Matches(input, @"\b[a-zA-Z0-9\#\+]*\b");
但上述方法似乎都不起作用。
谁能指出我正确的方向?
提前致谢。