This is my string:
Hello world, '4567' is my number.
If /g
(global modifier) was supported in .NET, There was no problem to get what I want, but now, I don't know what to do and need your help. I need match all digits (4567
) but splitted in single characters. I want it like this:
match 1: 4, match 2: 5, match 3: 6, match 4: 7
Thanks, Alireza
You can use Regex.Matches to get all the matches i.e. digits in your case.
var matches = Regex.Matches("Hello world, '4567' is my number.", "\\d");
foreach(Match match in matches)
Console.WriteLine(match.Value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With