I\'ve got a function spitting out \"Washington D.C., DC, USA\" as output. I need to capture \"Washington, DC\" for reasons that have to do with how I handle every single oth
matches = re.search(r'(\w+\s)(?:D\.C\.)(, \w\w)(?=\W)', location).group(1,2)
match = ''.join(matches)
When it says it is "non-capturing", that means it won't make a separate captured group for it. The text "D.C." is still in the match. See http://docs.python.org/library/re.html#match-objects