How to find all links with extension .jpg using regular expressions?

Good afternoon. Like the page to find links containing the extension only .jpg and ignore the other links?
Here's an example:
<a href="/index.html">Home</a>
<a href="xmas-greeting-dolly.jpg">xmas-greeting-dolly.jpg</a>
<a href="privacy.html"><font color="#003366">View 's Privacy Policy</font></a>

With the help of<a href="(.*?)\.jpg"(.*?)<\/a> it is clear that he will capture everything from the first line and before the first .jpg.
March 23rd 20 at 19:22
2 answers
March 23rd 20 at 19:24
preg_match_all("@<a href=\"([^\"]+?\.jpg)\"[^>]*>(.+?)</a>@i", $html, PREG_SET_ORDER)
so it finds only the first occurrence. but if several of them? - megane47 commented on March 23rd 20 at 19:27
With preg_match_all() - there is everything! - lester_Reichert70 commented on March 23rd 20 at 19:30
@megane47if you need the entire string, your expression it finds, on the question? hmm.
And the difference with the answer only in the bracket groups for the result...

How to find all links

xmas-greeting-dolly.jpg - this link.
<a href="xmas-greeting-dolly.jpg">xmas-greeting-dolly.jpg</a>
is a reference tag with the link in the href attribute and the link text. - Kurt_Beahan25 commented on March 23rd 20 at 19:33
March 23rd 20 at 19:26

Find more questions by tags Regular expressionsPHP