||There are oftentimes when you will have a string with a set delimiter, and you may wish to break up the string, stuffing the values between each delimiter into elements in an array. While this task may sound difficult, it is rather quite simple with VBScript.|
VBScript provides a function called
split, which, as the name implies, splits up a string into an array based on a delimiter.
split can only split up a single-dimension array.
Imagine that you had the following string:
How are you doing today?
What if you wanted to use the space as a delimiter, putting each word into an element of an array? With the split function, this is quite simple:
strSentence = "How are you doing today?"
aSentence = split(strSentence, " ")
At the conclusion of the above code snippet,
aSentence is an array with five elements:
With a bit of ingenuity, you can use the
split function to accomplish some really powerful and useful tasks with incredibly few lines of code. For example, you can perform batch database updates and batch database deletes using multiple checkboxes, the
split function, and some nifty SQL syntax. To learn more, be sure to read: Using Forms to Do Batch Database Updates and Using SQL Set Notation to do Batch Deletes!
split has an inverse function, one that does the opposite. This function,
join, converts an array into a string. To learn more about
join, be sure to read the FAQ: How can I convert the contents of an array into a string?
For more preliminary information on
split, be sure to read: Parsing with