I have a string
$str = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor <a href="http://example2.com">Do not want this text</a> incididunt ut labore et <a href="http://example.com">Want this text</a> dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in <a href="http://example.com">Do not want this text</a> reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
How can I extract the text between the first instance of an tag that links to http://example.com? I don't want the text that links to http://example2.com or the text in the second link that links to http://example.com.
I want to return 'Want this text'. Any idea how to do this?
Thanks!