import re
regex = re.compile(r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_\@.&+]|[!*'(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", flags=re.MULTILINE)
test_str = ("Xem thêm nội dung được đề xuất cho riêng bạn. https://vt.tiktok.com/ZSFNnnkf2/\n\n"
"Xem thêm nội dung được đề xuất cho riêng bạn. https://vt.tiktok.com/ZSFNnnkf2/\n\n"
"5.17 Xzt:/ 10/13 H@i.pQ QQ炫舞系列赠送龙年多重好礼,无需下载点开即玩! # QQ炫舞 # 游戏 # 龙年 https://v.douyin.com/iNYLXGru/ 复制此链接,打开Dou音搜索,直接观看视频!\n\n"
"0.51 p@q.Rx lpD:/ 12/19 真的好浪漫啊,公主请看@ https://v.douyin.com/iNYNd6Ns/ 复制此链接,打开Dou音搜索,直接观看视频!\n\n"
"Xem thêm tại https://www.facebook.com/story.php?story_fbid=pfbid0YNXQNNzHc39zjUhbMar7Fh2UsjooeemZkLJpQ1Q3phq8QvtEAY1Rc75qatoi6ku3l&id=100064769740799&mibextid=Nif5oz\n\n"
"xem thêm https://www.facebook.com/share/v/VDjQdshbUq72CQbe/?mibextid=oFDknk")
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