Return None if the pattern is a valid regular expression or
    a string describing why the pattern is invalid.

def regexp_error_msg(pattern):
    """
    Return None if the pattern is a valid regular expression or
    a string describing why the pattern is invalid.
    """
    try:
        re.compile(pattern)
    except re.error as e:
        return str(e)
    return None