fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. Regex rx = new Regex(@"^(\d{5})\s*([a-zA-Z].+)(?=\b\d+,)(\d+).*Tel.\s([\d ]+)$",
  9. RegexOptions.Compiled);
  10.  
  11. string text = "83661 Lenggries Marktstr. 14, Tel. 08042 91860";
  12.  
  13. MatchCollection matches = rx.Matches(text);
  14.  
  15. for (int count = 0; count < matches.Count; count++)
  16. Console.WriteLine(matches[count].Value);
  17. }
  18. }
Success #stdin #stdout 0.06s 21440KB
stdin
Standard input is empty
stdout
83661 Lenggries Marktstr. 14, Tel. 08042 91860