import re


def GetInstanceIdWithoutProject(instance_name):
  """Gets the instance id alone from the given instance name.

  Parses the given instance name and returns the instance id alone leaving
  the project id portion of the instance name.

  Args:
    instance_name: A string representing the instance name of the form
    domain:project:instance or project:instance or instance.
  Returns:
    A string that represents the instance id without project id part.
  """
  match = re.findall(r'(?::?)([a-z0-9\-]+)', instance_name)
  # The part after the last colon corresponds to instance name.
  return match[-1]