table, count = SplitStr(src$, token$[, multiple])
src$
into several pieces
by looking for the separator token$
in src$
. token$
must be a string
containing at least one character that shall act as a separator in src$
.
SplitStr()
will return a table containing all the pieces and the number
of pieces in the string as the second return value.
If the specified token does not appear in the source string, src$
is
returned.
Starting with Hollywood 7.1 there is a new optional argument named
multiple
. If this is set to True
, multiple occurrences of token$
next to each other will be considered a single occurrence. This can
be useful when using the space character as token$
and you want
this function to work with an arbitrary number of spaces between the
different parts.
Note that before Hollywood 8.0, token$
was limited to a string using
only one character. This limit has been lifted for Hollywood 8.0 and
the string can now be of arbitrary length.
token$
next to each other as a single token (defaults to False
) (V7.1)array, c = SplitStr("AmigaOS3|MorphOS|AmigaOS4|WarpOS|AROS", "|") For k = 1 To c Do NPrint(array[k - 1])The above code will print
AmigaOS3 MorphOS AmigaOS4 WarpOS AROS |
The variable c
will be set to 5 because SplitStr()
finds
five substrings and places them in the table specified.