Advertisement
Guest User

Match Numbers

a guest
Mar 25th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _08.Match_Numbers
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.  
  12.             var match = Regex.Matches(input, @"(^|(?<=\s))-?\d+(\.?\d+)?($|(?=\s))");
  13.             foreach (Match item in match)
  14.             {
  15.                 Console.Write(item.Value+" ");
  16.             }
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement