VBScript
Split
function
Complete VBScript reference manual
The Split function returns a 0-based one-dimensional array that contains a specified number of substrings.
Grammar
Split(expression[,delimiter[,count[,compare]]])
parameter
|
describe
|
expression
|
Required.Contains a string expression of a sub-string and a separator.
|
delimiter
|
Optional.Characters for identifying sub-string boundaries.The default is a space character.
|
count
|
Optional.The number of sub-strings required to be returned.-1 Indicates that all sub-strings are returned.
|
compare
|
Optional.The string comparison type to use is specified.
The following values can be used:
-
0 = VBBINARYCOMPARE - Performing binary comparison
-
1 = vbtextcompare - Perform text comparison
|
Instance 1
<script type="text/vbscript">
a=Split("W3CSchool is my favourite website")
for each x in a
document.write(x & "<br />")
next
</script>
The above example output results:
W3CSchool
is
my
favourite
website
Try it out . . .
Instance 2
Split text with delimeter parameters:
<script type="text/vbscript">
a=Split("Brown cow, White horse, Yellow chicken",",")
for each x in a
document.write(x & "<br />")
next
</script>
The above example output results:
Brown cow
White horse
Yellow chicken
Try it out . . .
Instance 3
Split text with delimeter parameters and count parameters:
<script type="text/vbscript">
a=Split("W3CSchool is my favourite website"," ",2)
for each x in a
document.write(x & "<br />")
next
</script>
The above example output results:
W3CSchool
is my favourite website
Try it out . . .
Instance 4
Split text using the delimeter parameter for text comparison:
<script type="text/vbscript">
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,1)
for each x in a
document.write(x & "<br />")
next
</script>
The above example output results:
Sun
Mon
Tues
WEDNES
Thurs
Fri
Satur
Try it out . . .
Instance 5
Split text using the delimeter parameter of binary comparison:
<script type="text/vbscript">
a=Split("SundayMondayTuesdayWEDNESDAYThursdayFridaySaturday","day",-1,0)
for each x in a
document.write(x & "<br />")
next
</script>
The above example output results:
Sun
Mon
Tues
WEDNESDAYThurs
Fri
Satur
Try it out . . .
Complete VBScript reference manual