| csvsplit |
(String str [, String delim [, int limit]]) |
yoix.string |
| |
Splits the string
str
up to a first encountered
NULL
character
(\0),
if any,
into an array of substrings based on delimiter supplied in
delim,
and returns the result.
By default, the delimiter is taken to be a comma.
If a double quote is the first character after a delimiter or at the start of
str,
then all characters, including instances of the delimiter character, up to the
next double quote are taken as a unit and the double quotes are trimmed off.
Any characters between the trailing double quote and the next delimiter are discarded.
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 = "John,Q.,\"Public, Jr.\", and stuff";
printf("%O\n", csvsplit(str));
prints
Array[4:0]
>^"John"
^"Q."
^"Public, Jr."
^" and stuff"
on standard output.
| | |
| Return: |
Array
| | |
| See Also: |
linesplit,
strjoin,
strsplit
|
|
Yoix is a registered trademark of AT&T Inc.
|