Skip to content

Modern String Split

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › String Library › String Library › Split

Split

Breaks a string into an Array at each delimiter.

Syntax

Split( s [, delim] [, ic] )

Notes

  • O(n*m) — Array( of T )

Examples

#import "std/containers"
#import "std/strings"
using strings, containers

dim as Array( of string ) parts = Split( "a,b,,c" )

print parts.Count                 '' 4 -- N delimiters always give N+1 fields
print parts[ 0 ] & "|" & parts[ 2 ]    '' a| -- the empty field is kept

'' Any delimiter, and the round trip always holds
dim as Array( of string ) words = Split( "one two three", " " )
print words.Count                 '' 3
print Join( words, "-" )          '' one-two-three

Library: String Library
Category: String Library
Documented under: The Functions

Clone this wiki locally