Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2004, 09:37 AM
Authorized User
 
Join Date: Jun 2003
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default mid-function not working (i did something wrong)

Hi,

i've put together this nice piece of code:

Code:
strTempContent="<table><tr><td>testje</td></tr></table>"

response.write strTempContent&"<br>"

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
 
Old February 10th, 2004, 09:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

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)

 
Old February 10th, 2004, 09:50 AM
Authorized User
 
Join Date: Jun 2003
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
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 :)
 
Old February 11th, 2004, 04:58 AM
Authorized User
 
Join Date: Jul 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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







Similar Threads
Thread Thread Starter Forum Replies Last Post
Contains function call not working correctly cnatale XSLT 7 May 8th, 2008 07:53 AM
mid umeshtheone Beginning VB 6 1 June 11th, 2007 02:49 PM
Using MID in SQL server rtr1900 Classic ASP Databases 0 December 13th, 2005 12:21 PM
search function not working locally Henry 8 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 December 19th, 2004 12:31 PM
Chapter 6 Edit function isn't working Graham76 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 3rd, 2004 10:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.