code: def strip_comment_line_with_symbol(line, start):
      
      parts = line.split(start)
      counts = [len(findall(r'(?:^|[^"\\]|(?:\\\\|\\")+)(")', part))
                for part in parts]
      total = 0
      for nr, count in enumerate(counts):
          total += count
          if total % 2 == 0:
              return start.join(parts[:nr + 1]).rstrip()
      else:  # pragma: no cover
          return line.rstrip()
docs: Strip comments from line string.