9. The text is given. Display the numbers in the text.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace App
{
class Program
{
public static void Main()
{
Console.Write("Enter the text: ");
string text= Console.ReadLine();
string[] numbers = Regex.Split(text, @"\D+");
foreach (string value in numbers)
{
if (!string.IsNullOrEmpty(value))
{
int i = int.Parse(value);
Console.WriteLine("Number: {0}", i);
}
}
Console.ReadLine();
}
}
}
Comments
Leave a comment