Reputation: 53806
How can I match the href and 'a' vlaue in a link ?
So extract 'www.google.com' & 'test' from below :
<A HREF="www.google.com/test.html" title="test">test</A>
Here is what I am trying : '<A HREF=(.+).html'
but it is not matching ?
Upvotes: 1
Views: 84
Reputation: 180897
Regular expressions for HTML can be brittle to change, but a regex for this exact case would be;
<A HREF="\(.*\)" .*>\(.*\)</A>
Upvotes: 1
Reputation: 7395
Try this:
<A.*HREF\s*=\s*(?:"|')([^"']*)(?:"|').*>(.*)<\/A>
Group1 and Group2 will give you the desired result.
Upvotes: 1