Without separation:
var matches = Regex.Matches("Hello world, '4567' is my number 679.", "\\d");
for (int i = 0; i < matches.Count; i++)
Console.WriteLine(string.Format("Match {0}: {1}", i + 1, matches[i].ToString()));
, .
:
1: 4
2: 5
3: 6
4: 7
5: 6
6: 7
7: 9
, :
var matches = Regex.Matches(myString, "\\d");
string result = string.Empty;
for (int i = 0; i < matches.Count; i++)
result += string.Format("Match {0}: {1}", i + 1, matches[i].ToString() + ", ");
Console.WriteLine(result.Trim().Trim(','));
:
1: 4, 2: 5, 3: 6, 4: 7, 5: 6, 6: 7, 7: 9