import re
regex = re.compile(r"<iframe[^>]*src=[\"|']([^'\"]+)[\"|'][^>]*>", flags=re.IGNORECASE)
test_str = ("<iframe src=\"http://flashx.tv/embed-76oom84mwi54-640x360.html\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" width=\"640\" height=\"360\"></iframe>\n\n"
"<a href=\"http://fullpeliculas.com/mcfarland-usa/\">\n"
"<div class=\"im\">\n"
"<img src=\"http://fullpeliculas.com/wp-content/uploads/2014/11/McFarland-USA-150x150.jpg\">\n"
"</div>\n"
"<p>\n"
"McFarland: Sin lĂmites</p></a>")
match = regex.search(test_str)
if match:
print(f"Match 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