Output
Number: 05
Number: 40
Number: 30
Number: 10
Number: 44
string input = "There are 5 numbers in this string: 40, 30, and 10. 44"; | |
string[] numbers = Regex.Split(input, @"\D+"); | |
foreach (string value in numbers) | |
{ | |
if (string.IsNullOrEmpty(value)) continue; | |
if (int.TryParse(value, out var number)) | |
{ | |
Debug.WriteLine($"Number: {number,-3:D2}"); | |
} | |
} |