
April 12th, 2005, 05:48 AM
|
 |
Moderator From Beyond
|
|
Join Date: Sep 2004
Location: Israel
|
|
String Manipulation - finding text between two delimeters (ASP)
Code:
<%
Function GetBetween(str, leftDelimeter, rightDelimeter)
Dim tmpArr, result(), x
tmpArr=Split(str, leftDelimeter)
If UBound(tmpArr) < 1 Then
GetBetween=Array() : Exit Function
End If
ReDim result(UBound(tmpArr)-1)
For x=1 To UBound(tmpArr)
result(x-1)=(Split(tmpArr(x), rightDelimeter))(0)
Next
Erase tmpArr
GetBetween=result
End Function
'usage:
Dim strHtml, arrValues, x
strHtml="<table><tr><td>AAA</td><td>BBB</td><td>CCC</td></tr></table>"
arrValues=GetBetween(strHtml, "<td>", "</td>")
For x=0 To UBound(arrValues)
Response.Write(arrValues(x)&"<br />")
Next
%>
the above function would return array of strings which are found between the given delimeters.
for comments, problems or questions please reply here.
Happy Programming!
Last edited by Shadow Wizard : April 12th, 2005 at 05:53 AM.
|