Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default strip out html

    is there a function in asp to strip out html characters ?

    adam


    ceaseanddesist Guest

  2. Similar Questions and Discussions

    1. strip html tags from textarea content
      Hi, I'm really new to flex developing, I'm writing a page that have to retrieve some content from an xml file and display it in some form...
    2. How to strip HTML markup from string?
      Hello, I want to transform text with HTML markup to plain text. Is there some simple way how to do it? I can surely write my own function,...
    3. Strip Numbers
      Hey could someone help me out here.... I need to strip numbers from a passed variable ex. 3899007 all the numbers will have 990 (so that is...
    4. Strip html tags
      Thanks Kindler, I'm sure it will, but I get a strange error when trying :( I'll figure something out. Cheers, Rob http://robgt.com/...
    5. Control Strip Gone?????
      In article <2dd16f1c.0307031813.5a61dc27@posting.google.com>, Michael Graham <mgrahm@trib.com> wrote: Sometimes software will shut it off...
  3. #2

    Default Re: strip out html

    I wrote this function to shorten a paragraph of text which contained HTML
    and then show an ellipsis at the end of the string if it was over a certain
    number of characters. It accepts 3 parameters, the string, the minimum
    length in chraracters to shorten to and the maximum number of characters to
    display. It will strip out all of the HTML tags in a string. You can modify
    this function to not include the portion which shortens the string, and
    still strip out all of the HTML.

    Function ShortenHTML(inputString, minLength, maxLength)
    If inputString <> "" Then
    Dim theString, a, b, i, outputLimit, PunctuationString
    theString = Trim(inputString)
    Do
    a = InStr(a + 1, theString, "<")
    If a > 0 Then
    b = InStr(a, theString, ">")
    If b > 0 Then
    theString = Trim(Left(theString, a - 1)) & " " & Trim(Mid(theString, b +
    1))
    Else exitLoop = True
    End If
    a = 0
    Else exitLoop = True
    End If

    Loop Until exitLoop = True
    PunctuationString = ".!?:;,"
    outputLimit = maxLength
    For i = 1 To Len(PunctuationString)
    a = InStr(minLength, theString, Mid(PunctuationString, i, 1) & " ")
    If a > 0 And a < outputLimit Then outputLimit = a
    Next
    outputString = Left(theString, outputLimit)
    If Len(RTrim(theString)) > Len(RTrim(outputString)) Then outputString =
    RTrim(outputString) & "..."
    ShortenHTML = outputString
    End If
    End Function

    Hope that gets you started,
    bT

    "ceaseanddesist" <poorleno@ukip.com> wrote in message
    news:d6va7i$l9c$1@forums.macromedia.com...
    > is there a function in asp to strip out html characters ?
    >
    > adam
    >

    Brandon Taylor Guest

  4. #3

    Default Re: strip out html

    > I wrote this function to shorten a paragraph of text which contained HTML
    > and then show an ellipsis at the end of the string if it was over a
    certain
    > number of characters.
    Here's a similiar one that I wrote using Regex. It also checks to make sure
    that I don't break a word in the middle (only trims at the spaces).

    function getCaption(ByVal YourItem as String) as String
    ' use a regex to strip out HTML tags (you may not need
    ' this if you're not storing HTML in the db field
    dim r as New Regex("\<[^\>]+\>")
    dim caption as String = r.replace(YourItem, "") 'this replaces all tags
    with nothing (ie, strips them out)
    dim trimmedCaption as String
    dim strSpace as String = " "
    dim location as integer
    ' this get's the location of the last character before the first space
    after x number of characters (in this case, 40)
    location = (Instr(40,caption,strSpace) - 1)
    ' trim the caption and add the elipses
    trimmedCaption = (left(caption, location)) & "..."
    return trimmedCaption
    end function


    darrel Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139