part.put(new LongValue(head));
part.put(new LongValue(startPosition));
  public static Value preg_split(Env env,                                 String patternString,                                 String string,                                 @Optional("-1") long limit,                                 @Optional int flags)    throws Throwable  {    Pattern pattern = compileRegexp(patternString);    if (limit < 0)      limit = Long.MAX_VALUE;    ArrayValue result = new ArrayValueImpl();    int head = 0;    Matcher matcher = pattern.matcher(string);    long count = 0;        while ((matcher.find()) && (count < limit)) {      // If empty and we are to skip empty strings, then skip      if ((flags & PREG_SPLIT_NO_EMPTY) != 0) {        if (head == matcher.start()) {          head = matcher.end();          continue;        }      }            String value;            // If at limit, then just output the rest of string      if (count == limit - 1) {        value = string.substring(head);        head = string.length();      } else {        value = string.substring(head, matcher.start());        head = matcher.end();      }      if ((flags & PREG_SPLIT_OFFSET_CAPTURE) != 0) {                ArrayValue part = new ArrayValueImpl();        part.put(new StringValue(value));        part.put(new LongValue(head));                result.put(part);      } else {               result.put(new StringValue(value));      }      count++;            if ((flags & PREG_SPLIT_DELIM_CAPTURE) != 0) {       for (int i = 1; i <= matcher.groupCount(); i++) {          if ((flags & PREG_SPLIT_OFFSET_CAPTURE) != 0) {            ArrayValue part = new ArrayValueImpl();            part.put(new StringValue(matcher.group(i)));            part.put(new LongValue(matcher.start()));                        result.put(part);          } else {            result.put(new StringValue(matcher.group(i)));          }        }      }    }        if (head < string.length()) {            if ((flags & PREG_SPLIT_OFFSET_CAPTURE) != 0) {                ArrayValue part = new ArrayValueImpl();        part.put(new StringValue(string.substring(head)));        part.put(new LongValue(head));          result.put(part);      } else {        result.put(new StringValue(string.substring(head)));      }    }    return result;  }