public static HostAndPort parseLocator(String locatorHostAndPort)
      throws MembershipConfigurationException {
    final int portSpecificationStart = locatorHostAndPort.indexOf('[');

    if (portSpecificationStart == -1) {
      throw createBadPortException(locatorHostAndPort);
    }

    String host = locatorHostAndPort.substring(0, portSpecificationStart);

    int idx = host.lastIndexOf('@');
    if (idx < 0) {
      idx = host.lastIndexOf(':');
    }
    String start = host.substring(0, idx > -1 ? idx : host.length());
    if (start.indexOf(':') >= 0) { // a single numeric ipv6 address
      idx = host.lastIndexOf('@');
    }
    if (idx >= 0) {
      host = host.substring(idx + 1);
    }

    int startIdx = portSpecificationStart + 1;
    int endIdx = locatorHostAndPort.indexOf(']');

    if (endIdx == -1) {
      throw createBadPortException(locatorHostAndPort);
    }

    final int port;
    try {
      port = Integer.parseInt(locatorHostAndPort.substring(startIdx, endIdx));
    } catch (NumberFormatException e) {
      throw createBadPortException(locatorHostAndPort);
    }
    return new HostAndPort(host, port);
  }
parse locators & check that the resulting address is compatible with the given address

@param locatorsString a DistributionConfig "locators" string
@param bindAddress optional address to check for loopback compatibility
@return addresses of locators
geode-membership/src/main/java/org/apache/geode/distributed/internal/membership/api/LocatorConfigurationParser.java