U
User N
I need a re that matchs an HTML anchor element, extracting the
href and text, given some of the text. For example, given the
following two line input:
<a href="a">bogus</a><a href="b">foobar</a>
<a href="c"><b>foo</b>bar</a>
I want to match the anchors that contain "bar" in the text. A simple
attempt might look like:
<a\s+href=\"(.+?)\">(.*?bar)</a>
but that actually matches the entire first line. I think some kind of
negative lookahead is needed, but can't quite figure it out. Any ideas?
href and text, given some of the text. For example, given the
following two line input:
<a href="a">bogus</a><a href="b">foobar</a>
<a href="c"><b>foo</b>bar</a>
I want to match the anchors that contain "bar" in the text. A simple
attempt might look like:
<a\s+href=\"(.+?)\">(.*?bar)</a>
but that actually matches the entire first line. I think some kind of
negative lookahead is needed, but can't quite figure it out. Any ideas?