fork download
  1. import re
  2. p = re.compile(r'^(.*?)(\b\d+\b)(.+?)\b(ste|st|ave|blvd)\b\s*(.*)$')
  3. p2 = re.compile(r'^(.*?)(\b\d+\b)(.+)\b(ste|st|ave|blvd)\b\s*(.*)$')
  4. s = "the fashion potential hq 116 w 23rd st ste 5 5th floor new york ny 10011"
  5. m = p.search(s)
  6. if m:
  7. n = p2.search(s)
  8. if n:
  9. print([m.groups(), n.groups()])
Success #stdin #stdout 0.02s 9016KB
stdin
Standard input is empty
stdout
[('the fashion potential hq ', '116', ' w 23rd ', 'st', 'ste 5 5th floor new york ny 10011'), ('the fashion potential hq ', '116', ' w 23rd st ', 'ste', '5 5th floor new york ny 10011')]