code: public static String toBPMNIdentifier(String str) {
  
          str = str.replaceAll("\\s+",
                               "");
          StringBuilder sb = new StringBuilder(str.length());
  
          for (int i = 0; i < str.length(); i++) {
              char c = str.charAt(i);
              if (i == 0) {
                  if (isNCNameStart(c)) {
                      sb.append(c);
                  } else {
                      sb.append(convertNonNCNameChar(c));
                  }
              } else {
                  if (isNCNamePart(c)) {
                      sb.append(c);
                  } else {
                      sb.append(convertNonNCNameChar(c));
                  }
              }
          }
          // return and strip leading digits
          return sb.toString().replaceFirst("^\\d*", "");
      }
docs: Converts a string to a valid BPMN Identifier,
  replacing invalid characters, e.g. Unicode chars
  with their URL encoded equivalents, without the '%'. For example
  "BP日" -> "BPE697A5"
  @param str - input string
  @return - valid BPMN id created from input string