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.
我正在尝试在 .NET 中获取正则表达式捕获的偏移量,就像.IndexOf()会返回一样。有没有办法做到这一点?
.IndexOf()
的结果Regex.Match将是一个Match对象。检查那个的 Index 属性
Regex.Match
Match
Match m = Regex.Match(input, pattern); int i = m.Index;
hth