code: private static String trimMarksFromAffix(String affix) {
          boolean hasBidiMark = false;
          int idx = 0;
          for (; idx < affix.length(); idx++) {
              if (isBidiMark(affix.charAt(idx))) {
                  hasBidiMark = true;
                  break;
              }
          }
          if (!hasBidiMark) {
              return affix;
          }
  
          StringBuilder buf = new StringBuilder();
          buf.append(affix, 0, idx);
          idx++;  // skip the first Bidi mark
          for (; idx < affix.length(); idx++) {
              char c = affix.charAt(idx);
              if (!isBidiMark(c)) {
                  buf.append(c);
              }
          }
  
          return buf.toString();
      }
docs: Remove bidi marks from affix