changing link's target to blank page

C

Cesar Garcia H

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
 
J

Joshua Flanagan

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top