import re
regex = re.compile(r"[a-zA-Z0-9-_.]+@[a-zA-Z0-9-_.]+")
test_str = ("boleh di kirim ke email saya ekoprasetyo.crb@outlook.com tks...\n"
"boleh minta kirim ke db.maulana@gmail.com. \n"
"dee.wien@yahoo.com. .\n"
"deninainggolan@yahoo.co.id Senior Quantity Surveyor\n"
"Fajar.rohita@hotmail.com, terimakasih bu Cindy Hartanto\n"
"firmansyah1404@gmail.com saya mau dong bu cindy\n"
"fransiscajw@gmail.com \n"
"Hi Cindy ...pls share the Salary guide to donny_tri_wardono@yahoo.co.id thank a")
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