This question already has an answer here:
Okay - this has boggled me for days. I've tried regex with negative lookahead, but to no avail.
Basically, in PHP, I need to parse conversation threads and extract the LAST occurrence of http links that can occur by itself, or in a consecutive group of 2 or more. So, in example 1, it should return the last link, but in example 2, it should return the last 3 links.
I don’t need to achieve this with a single regex, but I’m not sure what other approaches to try. Any help would be appreciated!!
EXAMPLE 1:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In pharetra elementum dui vel pretium. Quisque rutrum mauris vitae turpis hendrerit facilisis. Sed ultrices imperdiet ornare.
EXAMPLE 2:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
In pharetra elementum dui vel pretium. Quisque rutrum mauris vitae turpis hendrerit facilisis. Sed ultrices imperdiet ornare.
http://sample.com/24689.png
http://sample.com/13578.png
http://sample.com/98761.png
</div>