code: def compile(self, code):
          
          is_plain_text = True
          compiled_regex = r""
          for chunk in self.delimiter_regex().split(code):
              if is_plain_text:
                  compiled_regex = compiled_regex + simex_escape(chunk, flexible_whitespace=self._flexible_whitespace)
              else:
                  stripped_chunk = chunk.strip()
                  if stripped_chunk in self._regexes.keys():
                      compiled_regex = u"{0}{1}".format(
                          compiled_regex,
                          self._regexes[stripped_chunk]
                      )
                  else:
                      raise KeyNotFound("'{0}' not found in keys")
              is_plain_text = not is_plain_text
          if self._exact:
              compiled_regex = r"^" + compiled_regex + r"$"
          return compile(compiled_regex)
docs: Compile a simex code (e.g. <a href="{{ url }}">{{ anything }}</a>) to regex.
  
          Returns regex.