# $str.split

Splits a string to an array

Usage

    $str.split(<separator>,<data>[,<flags>[,<maxfields>]])

Description

Splits the <data> string by <separator> and returns an array of substrings.
<flags> may be a combination of the characters 's', 'w', 'r' and 'n'.
If s is specified, <separator> matching is case sensitive, otherwise it is case insensitive.
If w is specified, <separator> is treated as a wildcard-type regular expression (with * and ? wildcards).
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 neither w and r are specified <separator> is treated as a simple string to be matched.
If 'n' is specified then any resulting empty fields are discarded.
If <maxfield> is specified, then at most <maxfields> items are returned in the array (i.e. the last item may be not completely split).

Syntax Specification

    <array> $str.split(<separator:string>,<data:string>[,<flags:string>[,<maxfields:integer>]])

Examples

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

Regexp splitting:

        %Test[] = $str.split("[ ]*[0-9][0-9]*-","AllOfThem: 1-Balboy 2-Pragma 3-Iakkolo 4-Crocodile",r)
        echo %Test[]
        %Test[] = $str.split("Y*H","hihiYeaHhohohoyeahYepYEAHhi",sw)
        echo %Test[]

If used outside of an array context, a comma-separated list of substrings is returned:

        echo $str.split("[ ]*","Condense spaces and change     all       it in commas",r)

Index, Functions

KVIrc 4.2.0.6190 Documentation
Generated by root at Mon Jul 22 18:18:08 2013