May want to try something like this `(?P<quote>['"]).*?(?P=quote)`? (from http://docs.python.org/2/library/re.html)