Regex to select certain A tags
I'm trying to create a regex pattern to extract A tags in html that have contain a specific keyword in the href attribute.

For example, if I have a block of HTML such as:

    <p>Lorem ipsum dolar site amet <a href="http://foo.com">a link</a>. Ut enim ad minim veniam, quis nostrud <a href="http://bar.com">another Link</a>.

How can I extract the entire A tag (<a href="http://foo.com">a link</a>) if it's href attribute contains the keyword "foo"?

Any advice would be much appreciated!
Regex to select certain A tags
===

I'm trying to create a regex pattern to extract A tags in html that have contain a specific keyword in the href attribute.

For example, if I have a block of HTML such as:

    <p>Lorem ipsum dolar site amet <a href="http://foo.com">a link</a>. Ut enim ad minim veniam, quis nostrud <a href="http://bar.com">another Link</a>.

How can I extract the entire A tag (<a href="http://foo.com">a link</a>) if it's href attribute contains the keyword "foo"?

Any advice would be much appreciated!