how to check is a string is a valid regex - python?,re.compile('[')