code: public static ValueWithPos<String> ibanFormatWithPos(final ValueWithPos<String> pentry) {
      if (pentry == null) {
        return null;
      }
      if (StringUtils.isNotEmpty(pentry.getValue())) {
        final StringBuilder ibanSb = new StringBuilder(pentry.getValue().length());
        int pos = 0;
        int posformated = 0;
        for (final char charCode : pentry.getValue().toCharArray()) {
          if (CharUtils.isAsciiAlphaUpper(charCode) || CharUtils.isAsciiNumeric(charCode)) {
            if (pos > 0 && pos % BLOCK_LENGTH == 0) {
              ibanSb.append(SEPARATOR);
              if (posformated <= pentry.getPos()) {
                pentry.setPos(pentry.getPos() + 1);
              }
              posformated++;
            }
            ibanSb.append(charCode);
            pos++;
            posformated++;
          } else {
            if (posformated < pentry.getPos()) {
              pentry.setPos(pentry.getPos() - 1);
            }
          }
        }
        pentry.setValue(ibanSb.toString());
        if (pentry.getPos() < 0) {
          pentry.setPos(0);
        } else if (pentry.getPos() >= ibanSb.length()) {
          pentry.setPos(ibanSb.length());
        }
      }
      return pentry;
    }
docs: format iban to four character blocks.
  
  @param pentry string to format and cursor position
  @return formated string with new cursor position