@Override
  public void transform(Column[] columns, ColumnBuilder builder) throws Exception {
    Binary[] inputs = columns[0].getBinaries();
    boolean[] isNulls = columns[0].isNull();

    int count = columns[0].getPositionCount();

    if (index == -1) {
      for (int i = 0; i < count; i++) {
        if (isNulls[i]) {
          builder.appendNull();
        } else {
          String str = inputs[i].toString();

          String[] splitResult = str.split(regex);
          builder.writeInt(splitResult.length);
        }
      }
    } else {
      for (int i = 0; i < count; i++) {
        if (isNulls[i]) {
          builder.appendNull();
        } else {
          String str = inputs[i].toString();

          String[] splitResult = str.split(regex);
          if (index < splitResult.length) {
            builder.writeBinary(new Binary(splitResult[index].getBytes()));
          } else {
            builder.appendNull();
          }
        }
      }
    }
  }
This function splits string from an input series according to given regex.
library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexSplit.java