|
Subject:
|
mid-function not working (i did something wrong)
|
|
Posted By:
|
Haroldd
|
Post Date:
|
2/10/2004 8:37:36 AM
|
Hi,
i've put together this nice piece of code:
strTempContent="<table><tr><td>testje</td></tr></table>"
response.write strTempContent&"<br><hr>"
do while ((instr(1,strTempContent,"<")<>0) and (instr(1,strTempContent,">")<>0))
posBegin=instr(1,strTempContent,"<")
posEnd=instr(1,strTempContent,">")
string1=mid(strTempContent,posBegin,posEnd)
%><script>alert('<%=strTempContent%>' + ' --- ' + <%=posBegin%>+' - '+<%=posEnd%> + ' --- ' + '<%=string1%>')</script><%
strTempContent=replace(strTempContent,string1,"")
loop
The purpose of the script is to filter the html-tags out of the variable "strTempContent". This works fine for the first 3 tags (<table><tr><td>), but then it suddenly wants to replace the following tag: "</td></tr><" instead of "</td>". i really don't get it because the mid-function is called with these arguments: mid("testje</td></tr></table>",7,11). this should return "</td>" and not "</td></tr><". What am i missing??
Greetz,
Harold
|
|
Reply By:
|
Jonax
|
Reply Date:
|
2/10/2004 8:43:10 AM
|
The parametres of mid aren't begin and end, but begin and length...
So this: mid("testje</td></tr></table>",7,11)
Should be this: mid("testje</td></tr></table>",7,5)
|
|
Reply By:
|
Haroldd
|
Reply Date:
|
2/10/2004 8:50:10 AM
|
quote: Originally posted by Jonax
The parametres of mid aren't begin and end, but begin and length...
So this: mid("testje</td></tr></table>",7,11)
Should be this: mid("testje</td></tr></table>",7,5)
i'm very ashamed now 
but thanks a lot
|
|
Reply By:
|
kosla78
|
Reply Date:
|
2/11/2004 3:58:44 AM
|
Check out Regular Expressions for ASP. They are more efficient when it comes to that kind of tasks..Try a search in Google
Cheers
Kostas Lagos
|