>>> re.compile(r'''[^'"]*#[^'"]*''').match("'#") >>> re.compile(r'''[^'"]*#[^'"]*''').match("#'") <_sre.SRE_Match object at 0xb7cfc448>