Trying to match a C-like string, so that inside quotes, only non-quotes or backslash-escaped quotes are allowed: >>> p = re.compile(r'"([^"]|\\")*"') >>> p.match(r'"quote: \" test"').group() '"quote: \\"' But how come that wasn't greedy, and this is? V=== All I added was this dollar sign... >>> p = re.compile(r'"([^"]|\\")*"$') >>> p.match(r'"quote: \" test"').group() '"quote: \\" test"'