python Copy code import re
pattern = re.compile(r"(?:https?|ftp)://[^\s/$.?#].[^\s]*") with open("large_file.txt", "r") as f: matches = [pattern.search(line) for line in f] It works, but it’s painfully slow on large datasets. I tried using find all instead of search, but it didn’t help much.