def is_valid_regex(string):
try:<EOL><INDENT>re.compile(string)<EOL>is_valid = True<EOL><DEDENT>except re.error:<EOL><INDENT>is_valid = False<EOL><DEDENT>return is_valid<EOL>
Checks whether the re module can compile the given regular expression.

Parameters
----------
string: str

Returns
-------
boolean