strsplit()

Splits strings using delimiters.

Synopsis

dyn_string strsplit(string line, string/char delim);

Parameters

Parameter Description
line Line of text
delim Delimiter

Return value

List of substrings. The number of elements in the list depends on the number delimiters found.

Errors

missing or incorrect arguments

Description

Splits the string line into a list <dyn_string> of substrings. line is split at all occurrences of a delimiter contained in the string delim. These delimiters in line are lost and no longer occur in the <dyn_string> list of substrings. If line contains n delimiters, <dyn_string> will contain n+1 substrings. If the final delimiter in line is also the last character in the string, <dyn_string> only contains n substrings and the last (empty) substring is ignored.

Example

main()
{
  string line="This is a test";
  dyn_string split;
  split=strsplit(line, " ");
  // The result is
  DebugN("Part 1= ", split[1]); // This
  DebugN("Part 2= ", split[2]); // is
  DebugN("Part 3= ", split[3]); // a
  DebugN("Part 4= ", split[4]); // test
}

Assignment

Strings

Availability

CTRL