NastySwipy

RegEx Lab - 03. Match Hexadecimal Numbers

May 21st, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4.  
  5. namespace _10a_Regular_Expressions_RegEx_Lab
  6. {
  7.     class Regular_Expressions_RegEx_Lab
  8.     {
  9.        static void Main(string[] args)
  10.         {
  11.             string input = Console.ReadLine();
  12.             Regex reg = new Regex(@"\b[0x]*?[0-9A-F]+\b");
  13.             var matches = reg.Matches(input).Cast<Match>().Select(m => m.Value).ToArray();
  14.             //Thiw below is working only in ".NET Core"!?
  15.             //MatchCollection matches = reg.Matches(input);
  16.             Console.WriteLine(string.Join(" ", matches));
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment