Matching anchor tags

View: New views
2 Messages — Rating Filter:   Alert me  

Matching anchor tags

by Ian Skinner-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to match everything in an anchor tag, except the target
property.  I have this regex:
<(/?)a([^>]*)target="[^"]*"([^>]*)>

Which is working well for the opening <a>nchor tag.  But it does not
match the closing tag because a closing tag does not have a target
property.  How would I make the entire 'target="[^"]" in the middle
optional?

I tried wrapping it in parenthesis and putting a '?' after it, but that
does not seem to work.
<(/?)a([^>]*)(target="[^"]*")?([^>]*)>

Thank You
Ian


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/regex/message.cfm/messageid:1209
Subscription: http://www.houseoffusion.com/groups/regex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21

Re: Matching anchor tags

by Peter Boughton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can't figure out what you're attempting to do... can you re-explain
the aim of the expression?

Do you want to match the opening tag and the closing tag, or just one
or the other?
Are you attempting to remove/replace the target tag, or everything
except it, or something else?

A closing tag is just </a> - no need to complicate things unless you
need to link it to the related opening tag for some reason?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/regex/message.cfm/messageid:1210
Subscription: http://www.houseoffusion.com/groups/regex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21