import re regex = r'\bsrcset="[^"]* (https?://\S+)\s+1200w"' test_str = """srcset=\"https://c...content-available-to-author-only...g.co/w/articles/1/5ca/f022bb06dc.png 150w, https://c...content-available-to-author-only...g.co/w/articles/2/5ca/f022bb06dc.png 300w, https://c...content-available-to-author-only...g.co/w/articles/3/5ca/f022bb06dc.png 600w, https://c...content-available-to-author-only...g.co/w/articles/4/5ca/f022bb06dc.png 1200w\"""" matches = re.search(regex, test_str) if matches: print(matches.group(1))