Removing anchor tags from recordset

Discussion in 'ASP General' started by John Smith, May 16, 2004.

  1. John Smith

    John Smith Guest

    How would I strip all <a href=""></a> tags from a block of text using
    ASP?

    I assume you would need to find "<" and ">" tags, but I am not sure
    how you would actually remove it from the text. Any help would be
    greatly appreciated!


    Thank you!
     
    John Smith, May 16, 2004
    #1
    1. Advertisements

  2. John Smith

    Evertjan. Guest

    John Smith wrote on 16 mei 2004 in microsoft.public.inetserver.asp.general:
    Since you do not specify the language,
    I take the freedom of using jscript.

    Furthermore I suppose you want to keep the tag's innertext:

    t = 'zz <a href="blah.com">blah</a> zz'

    t = t.replace(/(<a[^>]+>)|(<\/a>)/gi,"")
     
    Evertjan., May 16, 2004
    #2
    1. Advertisements

  3. John Smith

    John Smith Guest

    On 16 May 2004 08:09:06 GMT, "Evertjan."

    :John Smith wrote on 16 mei 2004 in microsoft.public.inetserver.asp.general:
    :
    :> How would I strip all <a href=""></a> tags from a block of text using
    :> ASP?
    :>
    :> I assume you would need to find "<" and ">" tags, but I am not sure
    :> how you would actually remove it from the text. Any help would be
    :> greatly appreciated!
    :>
    :
    :Since you do not specify the language,
    :I take the freedom of using jscript.
    :
    :Furthermore I suppose you want to keep the tag's innertext:
    :
    :t = 'zz <a href="blah.com">blah</a> zz'
    :
    :t = t.replace(/(<a[^>]+>)|(<\/a>)/gi,"")


    I should have specified that I am using VBScript. I tried modifying
    the code above, but I have little experience with regular expressions
    in VBScript.
     
    John Smith, May 16, 2004
    #3
  4. John Smith

    Evertjan. Guest

    John Smith wrote on 16 mei 2004 in
    microsoft.public.inetserver.asp.general:

    t = "zz <a href='blah.com'>blah</a> zz"

    Set regEx = New RegExp
    regEx.Pattern = "(<a[^>]+>)|(<\/a>)"
    regEx.IgnoreCase = True
    regEx.Global = True
    t = regEx.Replace(t, "")
     
    Evertjan., May 16, 2004
    #4
  5. John Smith

    John Smith Guest

    On 16 May 2004 15:52:43 GMT, "Evertjan."

    :John Smith wrote on 16 mei 2004 in
    :microsoft.public.inetserver.asp.general:
    :
    :> On 16 May 2004 08:09:06 GMT, "Evertjan."
    :>
    :>:John Smith wrote on 16 mei 2004 in
    :>:microsoft.public.inetserver.asp.general:
    :>:
    :>:> How would I strip all <a href=""></a> tags from a block of text
    :>:> using ASP?
    :>:>
    :>:> I assume you would need to find "<" and ">" tags, but I am not sure
    :>:> how you would actually remove it from the text. Any help would be
    :>:> greatly appreciated!
    :>:>
    :>:
    :>:Since you do not specify the language,
    :>:I take the freedom of using jscript.
    :>:
    :>:Furthermore I suppose you want to keep the tag's innertext:
    :>:
    :>:t = 'zz <a href="blah.com">blah</a> zz'
    :>:
    :>:t = t.replace(/(<a[^>]+>)|(<\/a>)/gi,"")
    :>
    :>
    :> I should have specified that I am using VBScript. I tried modifying
    :> the code above, but I have little experience with regular expressions
    :> in VBScript.
    :
    :
    :t = "zz <a href='blah.com'>blah</a> zz"
    :
    :Set regEx = New RegExp
    :regEx.Pattern = "(<a[^>]+>)|(<\/a>)"
    :regEx.IgnoreCase = True
    :regEx.Global = True
    :t = regEx.Replace(t, "")


    THANK YOU! :)
     
    John Smith, May 16, 2004
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.