fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. string pattern = @"[-+]?\d*\.?\d+(\d[-+]?\d+)?|\w+|[^\w\s]";
  12. string input = @"am i entitled for 0.5 day leave?";
  13.  
  14. foreach (Match m in Regex.Matches(input, pattern, RegexOptions.Singleline))
  15. {
  16. Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
  17. }
  18. }
  19. }
Success #stdin #stdout 0.08s 19708KB
stdin
Standard input is empty
stdout
'am' found at index 0.
'i' found at index 3.
'entitled' found at index 5.
'for' found at index 14.
'0.5' found at index 18.
'day' found at index 22.
'leave' found at index 26.
'?' found at index 31.