import re content="sdfdsf<title>aaaaa</title>ssss" ss = re.search(r"<title>(.*?)</title>", content) print(ss.group(1))