$split

Splits a string to an array
Syntax

$split(<separator>,<string>[,<flags>])

Description
Splits the <string> by <separator> and returns an array of substrings.
<flags> may be a combination of the characters s w and r.
If s is specified , <separator> matching is case sensitive, otherwise is case insensitive.
If w is specified , <separator> is treated as a wildcard-type regular expression (with * and ? wildcars).
If r is specified , <separator> is treated as a extended-type regular expression (with character classes, special escapes etc..).
If both w and r are specified w takes precedence.
If none of w and r are specified <separator> is treated as a simple string to be matched.
The returned value may be assigned to a dictionary too: it will be used to simulate an array.
Examples

    # Split the fields
    %test[] = $split(!,"Field0!Field1!Field2!Field3!!Field5")
    echo %test[]
    %i = 0
    while(%i < %test[]#)
    {
        echo "Field %i: %test[%i]"
        %i++;
    }
Regexp splitting:

    %Test[] = $split("[ ]*[0-9][0-9]*-","AllOfThem: 1-Balboy 2-Pragma 3-Iakkolo 4-Crocodile",r)
    echo %Test[]
    %Test[] = $split("Y*H","hihiYeaHhohohoyeahYepYEAHhi",cw)
    echo %Test[]
If used in "non-array" context it returns just a comma separated list of substrings:

    echo $split("[ ]*","Condense spaces and change     all       it in commas",r)
See also
$join()

Main index, Function index
KVirc 3.0.0 documentation
Generated by diego at Sat Jul 13 15:37:55 2002