Jump to content

Regular Expression


Little Goat

Recommended Posts

I'm trying to put together A regular expression that will match all of the following:

<a href="someurl.html">go to someurl!</a><a href='http://somesite.com/someurl.php' title="hi!">go to somesite!</a>

mainly just one that will pick up <a> tags with an href value, regardless of which quotes used, and which other attributes are specified. here is my regex that I'm hoping does that:

/<a[^>]*?href=\s*("|')(.*?)("|')[^>]*?>(.*?)<\/a>/is

also, is there a way to return what is in the href attribute and what is in between the tags? (I am tring to use JAVA, but PHP will work fine.)thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...