I want to match image url that start from "//" and end with ".jpg" or ".png" or "gif". so I made following regular expressions and it works but not all cases..
var pattern = /\/{2}.+?\.(jpg|png|gif)/gm;
The problem is, It also matches something that looks like this,
//pm.pstatic.net/dist/css/nmain.20201119.css"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="https://s.pstatic.net/static/www/u/2014/0328/mma_204243574.png
And this is not what I want obiously. I need to match last occurence of "//" and lazy match of ".png" or ".jpg" or "gif". In this case, It will be //s.pstatic.net/static/www/u/2014/0328/mma_204243574.png
What should I use to solve this problem?
+edit
The website that I want to scrape contains image url something looks like this.
<a href="javascript:;" style="background:url(//gd4.alicdn.com/imgextra/i4/2748816012/O1CN01gbXzeB1uHXhQ9eTVd_!!2748816012.jpg_30x30.jpg)
so normal image url matcher doesn't work.
also, It must be lazy match of ".jpg" because as you can see above url, it has image address like //gd4.alicdn.com/imgextra/i4/2748816012/O1CN01gbXzeB1uHXhQ9eTVd_!!2748816012.jpg_30x30.jpg
it needs to be end at first occurrence of ".jpg", otherwise I will only scrape 30x30 small image which I don't want. In this case, img url that I want is, //gd4.alicdn.com/imgextra/i4/2748816012/O1CN01gbXzeB1uHXhQ9eTVd_!!2748816012.jpg
