How do I select http://test.com/ out of this HTML:
<a target="_new" href="http://test.com/" title="test">$293.00</a>
I realize I should use a DOM parser, however its for a few lines of code and I’d rather just use regex.
I’ve tried this with no success:
preg_match('/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/', $html, $url);
Thanks.
You can solve this with lookarounds:
(?<=href=")means: find a position immediately afterhref=".*?— this is saved ingroups[0]"