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. Advertising

  2. John Smith

    Evertjan. Guest

    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,"")

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., May 16, 2004
    #2
    1. Advertising

  3. John Smith

    John Smith Guest

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

    :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:

    > On 16 May 2004 08:09:06 GMT, "Evertjan."
    > <> wrote:
    >
    >: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, "")



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., May 16, 2004
    #4
  5. John Smith

    John Smith Guest

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

    :John Smith wrote on 16 mei 2004 in
    :microsoft.public.inetserver.asp.general:
    :
    :> On 16 May 2004 08:09:06 GMT, "Evertjan."
    :> <> wrote:
    :>
    :>: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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spondishy

    Nesting Literal Control in anchor tags

    Spondishy, Mar 21, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,544
    Matt Berther
    Mar 21, 2005
  2. TS
    Replies:
    5
    Views:
    4,898
  3. Replies:
    0
    Views:
    1,891
  4. Replies:
    15
    Views:
    14,400
    hharda9791
    Apr 17, 2013
  5. Hung Huynh
    Replies:
    8
    Views:
    339
    Bob Barrows
    Sep 24, 2003
Loading...

Share This Page