code: def _trim_after_first_match(self, pattern, candidate):
          
          trailing_chars_match = pattern.search(candidate)
          if trailing_chars_match:
              candidate = candidate[:trailing_chars_match.start()]
          return candidate
docs: Trims away any characters after the first match of pattern in
          candidate, returning the trimmed version.