code: private static String wordShapeDigits(final String s) {
      char[] outChars = null;
  
      for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (Character.isDigit(c)) {
          if (outChars == null) {
            outChars = s.toCharArray();
          }
          outChars[i] = '9';
        }
      }
      if (outChars == null) {
        // no digit found
        return s;
      } else {
        return new String(outChars);
      }
    }
docs: Just collapses digits to 9 characters.
  Does lazy copying of String.
  
  @param s String to find word shape of
  @return The same string except digits are equivalence classed to 9.