split()

The strLib.split()system function splits a string into an array of substrings based on a specified delimiter.

Syntax

  strLib.split(
             target STRING | CHAR | DBCHAR | MBCHAR | UNICODE In, 
             delimiter STRING | CHAR | DBCHAR | MBCHAR | UNICODE In)
  returns (result STRING[])
target

Input can be any value that is assignment compatible with any of the above types.

delimiter

Input can be any value that is assignment compatible with any of the above types.

result

It returns an array of strings, each element representing the portion of the original string that was separated based on the delimiter.

Example

 function main()
           myStr String = “Customer department service”;

           sysLib.writeStdout(“Splitted string is: “); 
           sysLib.writeStdout(strLib.split(myStr, “ “)[1]);
           sysLib.writeStdout(strLib.split(myStr, “ “)[2]);
           sysLib.writeStdout(strLib.split(myStr, “ “)[3]);
  end

The output is as follows:

   Splitted string is: 
   Customer 
   department 
   service