I have a body from a post where the user can or can't insert an image. I need to retrieve each occurrence of that image on the post. That is the pattern:
<img src="/storage/USER_ID/articles/pictures/FILENAME">
So lets say I will have this body:
$body = "... Cras ut tristique est. Etiam porttitor elit velit, vitae consequat eros interdum ac. Nam in blandit ante.</p><p> </p><figure class="image"><img src="/storage/5/articles/pictures/1560534410321_a363bc0d804aec432567128ed10416ee.jpeg"></figure><p>Integer sed justo accumsan, consequat nulla at, tincidunt massa. Integer orna Etiam porttitor elit velit, vitae consequat eros interdum ac. Nam in blandit ante.</p><p> </p><figure class="image"><img src="/storage/5/articles/pictures/23456410321_a33456t604aec432567128ed10416ee.jpeg"></figure> j hgfjhf jfhfj hgf jh786 876 8 76fgj tfyt u ufgi uyu y gi iy gygg ...";
I want to retrieve the number 5
and the filename 1560534410321_a363bc0d804aec432567128ed10416ee.jpeg
and number 5
and the filename 23456410321_a33456t604aec432567128ed10416ee.jpeg
So in this scenario I think the pattern should be like this: retrieve any number and filename between <img src="/storage/
number /articles/pictures/
filename ">
This is what i have so far:
preg_match_all ('/<img src=\"\/storage\/(.*?)\/articles\/pictures\/(.*?)\.(.*?)\"\>/g', $body , $result);
How can I improve this REGEX to have a scenario where "
is replaced by '
?