throws Throwable
  private static Value pregReplaceStringImpl(Env env,					     Pattern pattern,					     ArrayList<Replacement> replacementList,					     String subject,					     long limit,					     Value countV,					     boolean isEval)    throws Throwable  {    if (limit < 0)      limit = Long.MAX_VALUE;    int length = subject.length();    Matcher matcher = pattern.matcher(subject);    StringBuilderValue result = null;    int tail = 0;    int replacementLen = replacementList.size();    while (matcher.find() && limit-- > 0) {      if (result == null)	result = new StringBuilderValue();            // Increment countV (note: if countV != null, then it should be a Var)      if ((countV != null) && (countV instanceof Var)) {        long count = ((Var) countV).getRawValue().toLong();        countV.set(new LongValue(count + 1));      }      // append all text up to match      if (tail < matcher.start())        result.append(subject, tail, matcher.start());      // if isEval then append replacement evaluated as PHP code      // else append replacement string      if (isEval) {        StringBuilderValue evalString = new StringBuilderValue();        for (int i = 0; i < replacementLen; i++) {          Replacement replacement = replacementList.get(i);          replacement.eval(evalString, matcher);        }        result.append(env.evalCode(evalString.toString()));      } else {        for (int i = 0; i < replacementLen; i++) {          Replacement replacement = replacementList.get(i);          replacement.eval(result, matcher);        }      }      tail = matcher.end();    }    if (tail == 0)      return new StringValueImpl(subject);        if (tail < length)      result.append(subject, tail, length);    return result;  }