Split regular expression into 2 capture groups
问题 Ok, my previous questions were answered ... I have one more, this one is more difficult for me... ^([A-Za-z]+\.[A-Za-z0-9_-]+\.domain\.com)$ Right now this expression produces only 1 capture group as noted with ^() ; How would I do 2 capture groups for this URL? (for IIS regular expression rewrite) 回答1: You can do this by enclosing the relevant portions like so: text = "city.state.domain.com" pattern = "^([^\.]+).([^\.]+).([^\.]+).([^\.]+)$" match = re.match(pattern, text) match.groups() #