SPLIT
SPLIT s, delim, byref words [, pairs] [USE expr]
Splits the string s
at the position of the given
delimiters delim
and returns an array words
with the splitted substrings. The optional parameter pairs
can be used to group words. The optional Use expr
is
applied to every splitted substring. If delim
contains more
than one character, each character representing a delimiter.
See SINPUT for an alternative command to split a string.
Example 1: Split a string using two delimiters
"/etc/temp/filename.ext"
s = "/.", v ' Splits the string using the delimiters "/" and "."
SPLIT s, FOR i = 0 TO UBOUND(v)
PRINT i; " ["; v(i); "]"
NEXT
' Output:
' 0 []
' 1 [etc]
' 2 [temp]
' 3 [filename]
' 4 [ext]
Example 2 : Using the argument “pairs”
"/etc/temp/filename.ext"
s = "/", v, "temp"
SPLIT s, FOR i = 0 TO UBOUND(v)
PRINT i;" [";v(i);"]"
NEXT
' Display
0 []
1 [etc/temp]
2 [filename.ext]
Example 3: Using “USE expr”
"/etc/temp/filename1.ext " ' additional spaces at the end of the string
s = "/", v, "temp" USE TRIM(x) ' trim(x) will remove spaces at the beginning
SPLIT s, ' and the end of the splitted strings;
' try the example without "USE TRIM(x)"
FOR i = 0 TO UBOUND(v)
PRINT i;" [";v(i);"]"
NEXT
' displays
' 0 []
' 1 [etc/temp]
' 2 [filename1.ext]
Code samples using SPLIT
blackjack.bas
BlackJack.bas
Calendar.bas
calendar.bas
coordplot.bas
CSV_Viewer.bas
gputmalc.bas
gui_cal.bas
irc-bot.bas
memory match game.bas
palm_cli.bas
palmcli.bas
pdocview.bas
radish.bas
scambling text.bas
scampling.bas
subversion.bas
TinyBASIC.bas
tracklog.bas
Weekday.bas
weekday.bas
zacalc.bas
String
ASC
BCS
BIN
CBS
CHOP
CHR
DISCLOSE
ENCLOSE
FORMAT
HEX
INSTR
JOIN
LCASE
LEFT
LEFTOF
LEFTOFLAST
LOWER
LTRIM
MID
OCT
REPLACE
RIGHT
RIGHTOF
RIGHTOFLAST
RINSTR
RTRIM
SINPUT
SPACE
SPC
SPLIT
SPRINT
SQUEEZE
STR
STRING
TRANSLATE
TRIM
UCASE
UPPER
VAL
If there is insufficient information on this page and you wish learn more about SPLIT,
please send an email to smallbasic@gmail.com. You can help to improve information about
SPLIT by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.