Home > lang > split 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar fa id ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
Split
StringArray = Split ( String AS String [ , Separators AS String , Escape AS String , IgnoreVoid AS Boolean ] )

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

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.

Separator and escape characters are just single one-byte ASCII characters. You cannot use this function to split a string with a non-ASCII character or a another string.

For example: Split(MyString, "\r\n") will split MyString by using "\r" or "\n" as separator, but not the full string "\r\n".

Example

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

() (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

(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

Gambas.Almost.Means.BASIC.!.Do you agree ?.

See also

String Functions