Split Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE


The Split function returns a zero-based, one-dimensional array that contains a specified number of substrings. ASP provides an easy to use split function which lets you dice and slice a string. The Split function separates a string into substrings and creates a one-dimensional array where each substring is an element.

The Syntax of the Split function is :-

Split(expression[,delimiter[,count[,compare]]])

Its Description is :-

Parameter Description
expression Required. A string expression that contains substrings and delimiters
delimiter Optional. A string character used to identify substring limits. Default is the space character
count Optional. The number of substrings to be returned. -1 indicates that all substrings are returned
compare

Optional. Specifies the string comparison to use.
Can have one of the following values:·

  • 0 = vbBinaryCompare - Perform a binary comparison ·
  • 1 = vbTextCompare - Perform a textual comparison

Example#1 :-

Code :-
dim txt,a
txt="Hello World!"
a=Split(txt)
document.write(a(0) & "<br />")
document.write(a(1))
Output :-
Hello
World!

There is One Mandatory Argument.

Example#2 :-
Its explains the Expression Argument

Code :-
<% mystring = "How now brown cow?" %>
<% myarray = Split(mystring) %>
<% =myarray(0) %>
<% =myarray(1) %>
<% =myarray(2) %>
<% =myarray(3) %>
Output :-
How
now
brown
cow?

There are Three Optional Arguments.

Example#3 :-
It explains the Delimiter Argument

Code :-
<% mystring = "How now brown cow?" %>
<% myarray = Split(mystring, "ow") %>
<% =myarray(0) %>
<% =myarray(1) %>
<% =myarray(2) %>
<% =myarray(3) %>
<% =myarray(4) %>
Output :-
H
n
br
n c
?

Example#4 :-
It explains Count Argument

Code :-
<% mystring = "How now brown cow?" %>
<% myarray = Split(mystring, " ", 2) %>
<% =myarray(0) %>
<% =myarray(1) %>
Output :-
How
now brown cow?

Example#5 :-
It explains the Compare Argument

Code :-
<% mystring = "How now brown cow?" %>
<% myarray = Split(mystring, "B", 2, 1) %>
<% =myarray(0) %>
<% =myarray(1) %>
Output :-
How now
rown cow?

 

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

+91-9967648641

+91-9967648641