code: def fullmatch(pattern, string, flags=0):
      
      # Build a version of the pattern with a non-capturing group around it.
      # This is needed to get m.end() to correctly report the size of the
      # matched expression (as per the final doctest above).
      grouped_pattern = re.compile("^(?:%s)$" % pattern.pattern, pattern.flags)
      m = grouped_pattern.match(string)
      if m and m.end() < len(string):
          # Incomplete match (which should never happen because of the $ at the
          # end of the regexp), treat as failure.
          m = None  # pragma no cover
      return m
docs: Try to apply the pattern at the start of the string, returning a match
      object if the whole string matches, or None if no match was found.