import re
regex = re.compile(r"<img[\w\W]+?srcSet=\"[^\"]+(?<img>https?:\/\/[^\" ]+)", flags=re.MULTILINE)
test_str = "<img data-test=\"v-img\" src=\"https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=752x\" alt=\"\" width=\"3200\" height=\"2400\" sizes=\"(max-width: 767px) 100vw, (max-width: 919px) calc(100vw - 32px), (max-width: 1278px) calc(100vw - 240px), 1024px\" draggable=\"false\" srcSet=\"https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=300x225 300w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=400x300 400w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=600x450 600w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=752x564 752w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=1024x768 1024w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=1200x900 1200w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=1504x1128 1504w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=2048x1536 2048w, https://cdn.dribbble.com/userupload/14099353/file/original-432bffd5a8a059dfee436b0653d1f13d.jpg?resize=2400x1800 2400w\" class=\"v-img content-block border-radius-8\" data-v-5e868365>"
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html