import re


def _parse_build_number(build_number):
  """Parses the build number.

  Args:
    build_number: The build number as text.
  Returns:
    build_number, build_number_without_product_code.
  Raises:
    ValueError: if the build number is invalid.
  """
  match = re.match(r"^([A-Z]+-)?([0-9]+)((\.[0-9]+)*)", build_number)
  if match is None:
    raise ValueError("Invalid build number: " + build_number)

  return match.group(1) + match.group(2) + match.group(3)