fork download
  1. import re
  2.  
  3. string_array = ["http://w...content-available-to-author-only...s.com/reference/regex/regex_match/",
  4. "tcp://192.168.2.1:1234/hello/how/are/you",
  5. "https://mail.google.com/mail/u/0/?tab=wm#inbox/15178022db56df29?projector=1"]
  6. e = re.compile("^(?:([A-Za-z]+):)?(\\/{0,3})([0-9.A-Za-z-]+)(?::(\\d+))?(?:\\/([^?#]*))?(?:\\?([^#]*))?(?:#(.*))?$");
  7.  
  8. for i in range(len(string_array)):
  9. m = e.match(string_array[i])
  10. print(m.groups())
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
('http', '//', 'www.cplusplus.com', None, 'reference/regex/regex_match/', None, None)
('tcp', '//', '192.168.2.1', '1234', 'hello/how/are/you', None, None)
('https', '//', 'mail.google.com', None, 'mail/u/0/', 'tab=wm', 'inbox/15178022db56df29?projector=1')