I'm building a regexp to get urls in img src attribute :
$string = 'Ut quo totam aperiam possimus recusandae
<img src="mylink.jpg"/>
Bo nostrum vero distinctio eligendi.
<img src="mylinktmpfileandsomeotherstuff.jpg"/>
<img src="myotherlink.jpg"/>
Lorem ipsum';
preg_match_all('/(?<=src=").+?(?=")/', $string, $matches);
var_dump($matches);
Which is giving :
array (size=1)
0 =>
array (size=3)
0 => string 'mylink.jpg' (length=10)
1 => string 'mylinktmpfileandsomeotherstuff.jpg' (length=34)
2 => string 'myotherlink.jpg' (length=15)
https://regex101.com/r/UA3lVf/1
How can I filter my search to only get urls who contains the word "tmpfile" in it ?
So I would get :
array (size=1)
0 =>
array (size=1)
0 => string 'mylinktmpfileandsomeotherstuff.jpg' (length=34)