fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string input = "Av. Rouxinol 101 - Sao Paulo - Brasil - CEP 04516-001 - Fone + 55 11 2151";
  9. Regex re = new Regex(@"(?:^|(?<=\s-\s)).*?(?:(?=\s-\s[^-]{8,})|$)", RegexOptions.Singleline);
  10. MatchCollection matches = re.Matches(input);
  11. foreach (Match m in matches) {
  12. Console.WriteLine(m);
  13. }
  14. }
  15. }
Success #stdin #stdout 0.07s 37336KB
stdin
Standard input is empty
stdout
Av. Rouxinol 101
Sao Paulo - Brasil
CEP 04516-001
Fone + 55 11 2151