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.
我需要一个匹配所有这些组合的 C# 正则表达式 -
ABC(以及后面的空格和零个或多个字符)
ABC(后面没有空格和任何数字)
ABC(和行尾)<-这是我无法弄清楚的
这是我到目前为止所拥有的 -
bool match = Regex.IsMatch(address, @"((ABC)?[\s+0-9*])");
我试过这个无济于事(还有很多其他的东西) -
bool match = Regex.IsMatch(address, @"((ABC)?[\s+0-9*$])");
/ABC(?: \w*|\d+|\n)/
\n匹配新行。
\n
也许这就是您正在寻找的:
/ABC(?: .*|\d+)?$/