Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace MarchFourteen
- {
- class Program
- {
- static void Main(string[] args)
- {
- string pattern = @"\d";
- Regex regex = new Regex(pattern);
- string text = "Hi there, my number is 12314";
- MatchCollection matchCollection = regex.Matches(text);
- Console.WriteLine($"{matchCollection.Count} hits found:\n{text}");
- foreach(Match hit in matchCollection)
- {
- GroupCollection group = hit.Groups;
- Console.WriteLine($"{group[0].Value} found at {group[0].Index}");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement