throws Throwable
  public static ArrayValue preg_grep(Env env,                                     String patternString,                                     ArrayValue input,                                     @Optional("0") int flag)    throws Throwable  {    // php/151b    Pattern pattern = compileRegexp(patternString);    Matcher matcher = null;    ArrayValue matchArray = new ArrayValueImpl();    for (Map.Entry<Value, Value> entry : input.entrySet()) {      Value entryValue = entry.getValue();      Value entryKey = entry.getKey();      matcher = pattern.matcher(entryValue.toString());      boolean found = matcher.find();      if (!found && (flag == PREG_GREP_INVERT))        matchArray.append(entryKey, entryValue);      else if (found && (flag != PREG_GREP_INVERT))        matchArray.append(entryKey, entryValue);    }    return matchArray;  }