我试图从使用Regex的一连串文本中获取电子邮件地址。
demo_text = """hsds hjdsjd ksdkj
Reason: 550 [email protected]... No such user
sdhjsdjh
"""
# the following code extracts the whole line "Reason: 550 [email protected]... No such user"
# how do I just extract "[email protected]"?
email = re.search("Reason: 550 (.+)... No such user", demo_text).group(0)