code: def is_valid_regex(string):
      
      try:
          re.compile(string)
          is_valid = True
      except re.error:
          is_valid = False
      return is_valid
docs: Checks whether the re module can compile the given regular expression.
  
      Parameters
      ----------
      string: str
  
      Returns
      -------
      boolean