I am practicing regex with C#. This is my code:
string test =
"this is whole new line, with different parameters 10.1.2.1, 10.1.5.1, 10.1.3.1";
string a = Regex.Match(test, "10.[0-9].[0-9]+.[0-9]+").Value;
Console.WriteLine(a);
The result is 10.1.2.1. It finds the first match and that’s it.
How can I perform this function recursively ? Do I need to add some extra code or is there a regex class which has this as a built in function (which I would prefer)?
You are explicitly asking for only one match, using the
Matchmethod. You should useMatchesinstead, and iterate over the result:That code will print the following: