Split string

An utility to split a string based on an character 

A procedure to use in Seeburger BIC Mapping Designer
It will extend your library for string handling

//    -----------------------------
//    Peter Lykkegaard, 22 mar 2019
//    -----------------------------
//    Split string into its sub components based input characters

//    TODO! Check paramteters if they are of valid type/content
//
//    Name: splitString
//    Description: 
//    Parameters
//        input$, alphanumerical / String which needs to be split
//        criteria$, alphanumerical / Character to split
//    Output, alphanumeric / array / Array of strings to return

local output$[];

#javastart

    final String input = _StrVar_INPUT.getString();
    final String criteria = _StrVar_CRITERIA.getString();

    String[] data;

    if ((criteria == "-") || (criteria == "+") || (criteria == "|"))
    {
        data = input.split("\\" + criteria + "|\\*|\\/");
    }
    else
    {
        data = input.split(criteria, 0);
    }
    
    int idx = 0;

    for (int i = 0; i < data.length; i++) 
    { 
        _StrVar_OUTPUT.getJuVar(idx, 2).setString(data[i]);
        idx++;
    }

#javaEnd
    
exitProc(output$);

 

Comments are closed