VBScript Split Function | Newbie Tutorial
Newbie Tutorial -- Learning Technology, Chasing Dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
VBScript Tutorial
VB TutorialVB UsageVB VariablesVB ProceduresVB ConditionsVB LoopsVB SummaryVB ExamplesVB FunctionsVB Keywords
VBScript Examples VBScript KeywordsVBScript Split Function
Complete VBScript Reference Manual
The Split function returns a zero-based one-dimensional array containing a specified number of substrings.
Syntax
Split(expression[,delimiter[,count[,compare]]])
| Parameter | Description |
|---|---|
| expression | Required. A string expression containing substrings and delimiters. |
| delimiter | Optional. The character used to identify substring boundaries. Default is the space character. |
| count | Optional. The number of substrings to be returned. -1 indicates return all substrings. |
| compare | Optional. Specifies the type of string comparison to use. Can take the following values: * 0 = vbBinaryCompare - Perform binary comparison * 1 = vbTextCompare - Perform text comparison |
Examples
Example 1
a=Split(" is my favourite website") for each x in a document.write(x & "") next
The above example outputs:
is
my
favourite
website
Try it Β»
Example 2
Using the delimeter parameter to split text:
a=Split("Brown cow, White horse, Yellow chicken",",") for each x in a document.write(x & "") next
The above example outputs:
Brown cow
White horse
Yellow chicken
Try it Β»
Example 3
Using delimeter parameter and count parameter to split text:
a=Split(" is my favourite website"," ",2) for each x in a document.write(x & "") next
The above example outputs:
is my favourite website
Try it Β»
Example 4
Using delimeter parameter with text comparison to split text:
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1) for each x in a document.write(x & "") next
The above example outputs:
Sun
Mon
Tues
WEDNES
Thurs
Fri
Satur
Try it Β»
Example 5
Using delimeter parameter with binary comparison to split text:
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,0) for each x in a document.write(x & "") next
The above example outputs:
Sun
Mon
Tues
WEDNESDAYThurs
Fri
Satur
Try it Β»
YouTip