Value value; if (matcher.group(i) != null) value = new StringValueImpl(matcher.group(i)); else value = NullValue.NULL;
String group = matcher.group(i);  if (group == null) continue;
  public static int preg_match(Env env,                               StringValue patternString,                               StringValue string,                               @Optional @Reference Value matchRef,                               @Optional int flags,                               @Optional int offset)  {    if (patternString.length() < 2) {      env.warning(L.l("Regexp pattern must have opening and closing delimiters"));      return 0;    }    Pattern pattern = compileRegexp(patternString);    Matcher matcher = pattern.matcher(string);    ArrayValue regs;    if (matchRef instanceof DefaultValue)      regs = null;    else      regs = new ArrayValueImpl();    if (! (matcher.find(offset))) {      matchRef.set(regs);      return 0;    }    boolean isOffsetCapture = (flags & PREG_OFFSET_CAPTURE) != 0;    if (regs != null) {      if (isOffsetCapture) {        ArrayValueImpl part = new ArrayValueImpl();        part.append(new StringValueImpl(matcher.group()));        part.append(new LongValue(matcher.start()));        regs.put(LongValue.ZERO, part);      }      else        regs.put(LongValue.ZERO, new StringValueImpl(matcher.group()));      int count = matcher.groupCount();      for (int i = 1; i <= count; i++) {        Value value;        if (matcher.group(i) != null)          value = new StringValueImpl(matcher.group(i));        else          value = NullValue.NULL;        if (isOffsetCapture) {          ArrayValueImpl part = new ArrayValueImpl();          part.append(value);          part.append(new LongValue(matcher.start(i)));          regs.put(new LongValue(i), part);        }        else          regs.put(new LongValue(i), value);      }      matchRef.set(regs);    }    return 1;  }