Split

From REALbasicWiki

Jump to: navigation, search

Contents

[edit] Prototype

Function Split( sourceString as String, delimiter as String = " " ) As String()

[edit] Description

Split returns a String array formed by splitting the sourceString and starting a new element each time the delimiter is encountered in the string. The delimiters are not included in the output. The delimiter can be any string but defaults to a single space. Split was added to REALbasic in version 5.5.

[edit] Discussion

[edit] Sample Code

dim sourceString as String = "One Two Three"
dim objectArray() as String = Split ( sourceString )

// display "Two"
MsgBox objectArray( 1 )


[edit] Splitting into characters

You can pass the empty string "" as delimiter to Split. Split will return an array containing the characters of the source string, as defined by its encoding.

dim characters() as String = Split("This is a test", "")

[edit] See also

Personal tools
related