471,319 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

changing link's target to blank page

Hi everybody...

I'm making an application that receives HTML and before showing it has
to format it in some way that all links that are inside that HTML must
have target attribute with "_blank" value... so, to do this I need a
regular expression that matches this :

<a href="http://www.abc.com/"> OR
<a href="http://www.abc.com/" target="somevalue">

but, doesnt match this

<a href="http://www.abc.com/" target="_blank">

Been more specific, I need a regular expression that matches a link
without target attribute, or with a target value different of "_blank"

Some ideas??

I tried googling... but... I didnt found anything.

Thanks in advance

Cesar Garcia H.
http://www.zapcome.com/zapblog/cesargarcia
Jul 21 '05 #1
1 1283
It might be easier to make it a 2 step process. Make a regular
expression that finds links (should be able to find one at regexlib or
other internet repository). Then with each result, run another regex
(or just use the IndexOf() method) to see if it contains a target attribute.
Cesar Garcia H wrote:
Hi everybody...

I'm making an application that receives HTML and before showing it has
to format it in some way that all links that are inside that HTML must
have target attribute with "_blank" value... so, to do this I need a
regular expression that matches this :

<a href="http://www.abc.com/"> OR
<a href="http://www.abc.com/" target="somevalue">

but, doesnt match this

<a href="http://www.abc.com/" target="_blank">

Been more specific, I need a regular expression that matches a link
without target attribute, or with a target value different of "_blank"

Some ideas??

I tried googling... but... I didnt found anything.

Thanks in advance

Cesar Garcia H.
http://www.zapcome.com/zapblog/cesargarcia

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Brandon Hoppe | last post: by
36 posts views Thread by randau | last post: by
6 posts views Thread by iwearwatches | last post: by
31 posts views Thread by Greg Scharlemann | last post: by
reply views Thread by Cesar Garcia H | last post: by
3 posts views Thread by Jason | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.