def remove_comments(string):
    pattern = '(\\".*?\\"|\\\'.*?\\\')|(/\\*.*?\\*/|//[^\\r\\n]*$)'
regex = re.compile(pattern, re.MULTILINE | re.DOTALL)

def _replacer(match):
    if match.group(2) is not None:
        pass
Using regex to remove comments from source files