Advertisements

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)

Advertisements

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

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

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!