I need a regex to scan JS files for any image paths it finds.
These paths would generally be nested as follows:
$img1 = "foo/bar.png";
$img2 = 'foo/bar.jpg';
$img3 = "{'myimg':'foo/bar.png'}";
I need a regex which will be able to pick up the whole image path inside the quotes, but sometimes nested inside a json string, or otherwise encoded... essentially, matching a whole image path by detecting just the existence of the extension (jpg|png|gif).
I have found a regex that works well in php, I need one that works with javascript.
$pattern = '~/?+(?>[^"\'/]++/)+[^"\'\s]+?\.(?>(?>pn|jpe?)g|gif)\b~';
How the form of regex pattern in javascript?
[^"']*\.(?:(?:pn|jpe?)g|gif)\bregex101.com/r/750x5s/1