AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
strsplit (String str1, String str2 [, int limit]) yoix.string
 
Splits the null-terminated string str1 into an array of substrings based on delimiters supplied in str2, and returns the result or NULL if str1 is NULL. An empty string delimiter (i.e., "") is special and means split str1 into individual characters. A NULL string delimiter suppresses splitting.

The optional limit argument sets the maximum number of substrings that will be generated. Additionally, if limit is less than zero, then its absolute value not only sets the maximum number of substrings that will be generated, but also sets the size of the returned array (any unused elements will be set to NULL). Setting limit to zero has the same effect as not supplying the argument at all.
 
 Example:   The program,
import yoix.stdio.*;
import yoix.string.*;

String  str = "one+++two+++three+++everything else...";

printf("%O\n", strsplit(str, "+++"));
prints
Array[4:0]
   >^"one"
    ^"two"
    ^"three"
    ^"everything else..."
on standard output.
 
 Return:   Array
 
 See Also:   csvsplit, linesplit, strcasecmp, strcat, strchr, strcmp, strcpy, strcspn, strdel, strdup, strfmt, strins, strjoin, strlen, strncasecmp, strncat, strncmp, strncpy, strpbrk, strrchr, strrstr, strspn, strstr, strtok

 

Yoix is a registered trademark of AT&T Intellectual Property.