Results 1 to 6 of 6

Thread: removing html

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Location
    Pittsburgh, PA
    Posts
    149
    Anybody know how to go about removing all html from user entered text?

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    How is the user to enter this ?

    You could use vb's replace function if it's small :
    Code:
    REPLACE "<HTML>", text1.text, ""
    Or are you looking at a whole web page type thing ???

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2000
    Location
    Pittsburgh, PA
    Posts
    149
    I could but the I would have to write a rplace for every html tag and then parse the text looking for hrefs,img,form... since the tags vary. I was hoping there was a better way to do it

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Just convert the < and > to &gt; and &lt;
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    J, awkward but I think needed. If you could give me an example of what this is for / the context you need this for would help.

    Josh, that would still keep :
    HTML from :
    <HTML>
    so he would get a load of extra words in his text.

    What you could do is use an array for all the tags, something like :
    Code:
    Dim ArrTag(5) as variant
    'Note : Arrays always start at 0, so me declaring a scope 
    of 5 spaces here really gives 6 - 0,1,2,3,4 and 5
    
    ArrTag = Array(<HTML>, <HEAD>, <BODY>, <SCRIPT>, <TABLE>, <TR>, <TD>)
    So you only type them once, put each tag into an array
    
    For i = 0 to ubound(ArrTag)
    'Go through all the array until the bottom entry is reached
        Replace ArrTag(i), Text1.text, ""
        ' change the tag with a blank space
    Next i

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    VBScript supports regular expressions now, right? I have some Perl code somewhere I wrote a couple years ago that will strip HTML tags from user text. What it basically would do is to find < and the next >, and strip them and everything in between.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width