1

I have a bunch of HTML code which contain these images:

<img alt=\"http://www.adsf1.net/static/1231.jpg\" width=\"100%\">
<img alt=\"http://www.1322.com/files/150818g58.jpg\" width=\"100%\">
<img alt=\"http://www.aerwef.org/sda/sdfawe.jpg\" width=\"100%\">

I manage to match these images with this regex

<img[^>]+\s*\/?>

But, I would like to get the url from the alt tag using JS, and store it into an array.

I would like to get a JS array like this (based on the above example)

["http://www.adsf1.net/static/1231.jpg", "http://www.1322.com/files/150818g58.jpg", "http://www.aerwef.org/sda/sdfawe.jpg"]

2 Answers2

2

You can try this regex :

<img alt=\\"(http[^"]*)\\".*

Hope this helps.

link : https://regex101.com/r/mI3hV1/1

bob
  • 4,595
  • 2
  • 25
  • 35
  • Thank you for your help! This regex made my day. I have modified a little base on yours to better match my questions. Anw, thanks a lot! – user3781968 Aug 18 '15 at 15:11
0

Thank you @pawan bhardwaj for the tips and clue. I have modified his code for a better match.

<img.*?alt=\\"(http[^"]*)\\".*?>

For others who are looking for something similar, hope this helps.