Using the official spec for the HTML5 srcset image candidate string, I've created the following regex:
/<img[^\>]*[^\>\S]+srcset=['"](?:([^"'\s,]+)\s*(?:\s+\d+[wx])(?:,\s*)?)+["']/gm
...Which should match the following tag:
<img srcset="image@2x.png 2x, image@4x.png 4x, image@6x.png 6x">
...And return the three filenames specified (image@2x.png
, image@4x.png
, image@6x.png
).
However, even though it matches, it's only returning the last one. See this Regex101 demo.
What am I doing wrong?