How to get offset of a Regex capture?
Question
I'm trying get the offset of a regex capture in .NET just like .IndexOf()
would return. Is there anyway to do that?
Solution
The result of the Regex.Match
will be a Match
object. Check the Index property of that
Match m = Regex.Match(input, pattern);
int i = m.Index;
hth
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow