fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var s = "w:/a\\bc::/12\\xyz";
  9. var r = new Regex(@"^\p{L}+[\p{L}\d:]*/[\p{L}\d]+\\[\p{L}\d]+$", RegexOptions.Compiled);
  10. //The pattern is alphabets then zero or more numbers,alphabets,colon//
  11. //then forward slash then one or more numbers,alphabets then backward slash//
  12. //then again one or more numbers,alphabets
  13. for (var q = 0; q < s.Length; ++q)
  14. for (var w = q; w <= s.Length; ++w)
  15. {
  16. var cur = s.Substring(q, w-q);
  17. if (r.IsMatch(cur))
  18. Console.WriteLine("FOUND: {0}", cur);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.05s 133824KB
stdin
Standard input is empty
stdout
FOUND: w:/a\b
FOUND: w:/a\bc
FOUND: bc::/12\x
FOUND: bc::/12\xy
FOUND: bc::/12\xyz
FOUND: c::/12\x
FOUND: c::/12\xy
FOUND: c::/12\xyz