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.
我有:
string cap = "OK|pz6u1"; var id = Regex.Match(cap, @"OK\|(.*?)").Groups[1].Value;
为什么 id 为空?
将您的代码更改为以下代码:
var id = Regex.Match(cap, @"OK\|(.*)").Groups[1].Value
你表达的问题是一个问号(?)。问号标记使前面的语句可选,所以它被省略了。