VBScript Split Function


Split :

A Split Function returns an array that contains a specific number of values splitted based on a Delimiter.

Syntax :

  1. expression, a Required parameter. The String Expression that can contain strings with delimiters.

  2. delimiter, an Optional Parameter. The Parameter, which is used to convert into arrays based on a delimiter.

  3. count, an Optional Parameter. The number of substrings to be returned, and if specified as -1, then all the substrings are returned.

  4. compare, an Optional Parameter. This parameter specifies which comparison method to be used.

    • 0 = vbBinaryCompare - Performs a binary comparison

    • 1 = vbTextCompare - Performs a textual comparison

Example :

<!DOCTYPE html>
<script language="vbscript" type="text/vbscript">

' Splitting based on delimiter comma '$'
a=Split("Red $ Blue $ Yellow","$")
For i=0 to b
   document.write("The value of array in " & i & " is :"  & a(i)& "<br />")


When the above code is saved as .HTML and executed in Internet Explorer, it produces the following result:

The value of array in 0 is :Red 
The value of array in 1 is : Blue 
The value of array in 2 is : Yellow