SplitMulti Function:
Split function variation that accepts multiple separators
Description:
Enhancement of the Split function that works with more than one separators. Separators can be two or more characters.
Syntax:
arrResult = SplitMulti(strText, separators)
Example:
<%
Dim i Dim strText Dim separators Dim arrResult strText ="one,two(three four)five" separators = Array(" ", ",", "(", ")") arrResult = SplitMulti(strText, separators) For i = 0 To UBound(arrResult) response.write arrResult(i) & "<br />" Next
'--- result: one two three four five
%>
ASP Source Code:
<%
Function SplitMulti(source, separators()) Dim k, sep '--- this is the "main" separator sep = separators(0) '--- replace all other separators in string with the main separator For k = 1 To UBound(separators) source = Replace(source, separators(k), sep) Next '--- now we can apply the standard Split function SplitMulti = Split(source, sep) End Function
%>
|