string_split

string_split — breaks a string into individual words.

Syntax

string_split (string, delimiters, max_words)

		

Arguments

string

Any character string.

delimiters

A character string containing delimiter characters.

max_words

The maximum number of words to separate.

Returns

A list containing at most (max_words + 1) elements, each of which is a string.

Description

This function breaks a string into individual words wherever it finds any one of the characters in the delimiters string. If max_words is zero or less, there is no limit to the number of words which may be generated. If max_words is greater than zero, then at most max_words words will be generated. If there are any characters remaining in the string once max_words words have been generated, then the remaining characters will be returned as the last element in the result list. If delimiters is the empty string, "", then the input string will be split at any white space.

Example

Gamma> string_split("This is a test","",0);
("This" "is" "a" "test")
Gamma> string_split("This is a test"," ",2);
("This" "is" "a test")
Gamma> string_split("This is a test","ie",0);
("Th" "s " "s a t" "st")
Gamma> string_split("12:05:29",":",-1);
("12" "05" "29")
Gamma> 
		

See Also

strchr, strrchr, strstr