import re


def StripSingleLineComments(
  string: str, start_comment_re: str = "(#|//)",
) -> str:
  """Strip line comments from a string.

  Args:
    string: The string to strip the comments of.
    start_comment_re: The regular expression to match the start of a line
      comment. By default, this matches Bash-style '#' and C-style '//'
      comments.

  Returns:
    The string.
  """
  comment_re = re.compile(f"{start_comment_re}.*")
  lines = [comment_re.sub("", line) for line in string.split("\n")]
  return "\n".join(lines)