code: public static boolean replaceStep(Matcher m, Substitution substitution, TextBuffer dest) {
          boolean firstPass = true;
          int c = 0, count = 1;
          while (c < count && m.find()) {
              if (m.end() == 0 && !firstPass) continue;  //allow to replace at "^"
              if (m.start() > 0) m.getGroup(MatchResult.PREFIX, dest);
              substitution.appendSubstitution(m, dest);
              c++;
              m.setTarget(m, MatchResult.SUFFIX);
              firstPass = false;
          }
          return c > 0;
      }
docs: Replaces the next occurrence of a matcher's pattern in a matcher's target by a given substitution, appending the
  result to a buffer but not writing the remainder of m's match to the end of dest.
  <br>
  The substitution starts from current matcher's position, current match not included.
  <br>
  You typically want to call {@code m.getGroup(MatchResult.TARGET, dest);} after you have called replaceStep()
  until it returns false, which will fill in the remainder of the matching text into dest.
  @param m a Matcher
  @param substitution a Substitution, typically a PerlSubstitution
  @param dest the TextBuffer this will write to; see Replacer.wrap()
  @return the number of replacements performed