/ lang / split
Split
Syntax

    StringArray = Split ( String AS String [ , Separators AS String , Escape AS String , IgnoreVoids AS Boolean ] )

Splits a string into substrings delimited by separators and escape characters.

- String is the string to split.
- Separators is a list of sperators characters.
- Escape is an escape character. Any separator characters enclosed between two escape characters are ignored in the splitting process. If Escape contains two characters, then the first is the starting escape character, and the second the ending one.
- IgnoreVoids tells Split() not to return void elements.

This function returns a string array filled with each detected substring. Separators and escape characters are not returned.

By default, the comma character is the separator, and there are no escape characters.

| If a string contains escape characters, then these escape characters must be duplicated.

### Examples

    DIM Elt AS String[]
    DIM Sb AS String

    Elt = Split(" Gambas Almost Means BASIC  !\n'Do you agree ?'", " \n", "'")

    FOR EACH Sb IN Elt
      PRINT "("; Sb; ") ";
    NEXT
    PRINT
    <hr>() (Gambas) (Almost) (Means) (BASIC) () (!) (Do you agree ?)

    Elt = Split(" Gambas Almost Means BASIC  !\n'Do you agree ?'", " \n", "'", TRUE)

    FOR EACH Sb IN Elt
      PRINT "("; Sb; ") ";
    NEXT
    PRINT
    <hr>(Gambas) (Almost) (Means) (BASIC) (!) (Do you agree ?)

    Elt = Split("(Gambas) (Almost) (Means) (BASIC) (!) (Do you agree ?)", " ", "()")

    FOR EACH Sb IN Elt
      PRINT Sb; ".";
    NEXT
    PRINT
    <hr>Gambas.Almost.Means.BASIC.!.Do you agree ?.

### See also

String Functions