The regular expression that will match one or more numerals in succession is:
\d+
You could apply it this way:
Regex.Matches(myString, @"\d+")
Which will return a collection of MatchCollection
object. This will contain the matched values.
You could use it like so:
var matches = Regex.Matches(myString, @"\d+");
if (matches.Count == 0)
return null;
var nums = new List<int>();
foreach(var match in matches)
{
nums.Add(int.Parse(match.Value));
}
return nums;
3
solved Regular Expression for numbers?