How do I add an option to increment the digit part of a regex by +1.
I have written the below example
What I have tried:
string input="dsfjl kfjd dsfds fds sd abc3, abc4, abc5 dsfdgfdf ggd gdfg dfg gdfg dfg gdf gf g abc13 abc14 abc20 abc21 abc22 dsfsdf abc13, abc4, abc5";
Regex rx = new Regex(@"(?:abc(\d+)\s*,?\s*){2,}abc(\d+)");
foreach (Match m in Regex.Matches(input,rx.ToString())) {
Console.WriteLine(m.Value);
}
Console.ReadKey();
The output generated is
abc3, abc4, abc5
abc13 abc14 abc20 abc21 abc22
abc13, abc4, abc5
But I want to get the output as
abc3, abc4, abc5
abc20 abc21 abc22
i.e. get only the consecutive matches that have the digits incremented by +1
How do I implement that in my code?