int (StringBuilder b, int midOffset, String replacement, int[] offsetToKeep) { b.replace(midOffset - 1, midOffset + 1, replacement); int shift = replacement.length() - 2; if (offsetToKeep[0] > midOffset) offsetToKeep[0] += shift; return midOffset + shift; }