import re
regex = re.compile(r"(?>https?:|).+?[:;]", flags=re.MULTILINE)
test_str = ("www.yahoo.com:описание1\n"
"http://site.ru:описание2\n"
"www.site3.org:описание3\n"
"http://w3k.biz:описание4\n"
"www.yahoo.su:описание5\n"
"http://w3k.biz;описание6\n"
"www.yahoo.su;описание7")
subst = ""
result = regex.sub(subst, test_str)
if result:
print(result)
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