I got a string representing users data.
What is the proper regex to extract domain in this string?
I know that I have to find all strings with 2 characters matching the condition that it comes after the last “.” after a “@”.
However I still failed to implement it.
Advertisement
Answer
JavaScript
x
15
15
1
import re
2
3
regex = r"@.+.([a-z]{2}),"
4
5
your_string = ("001,Francisca,Dr Jhonaci,jhonadr@abc.com,32yearsold,120.238.225.0n"
6
"002,Lavenda,Bocina,lavenboci@banck.ac.uk,50yearsold,121.186.221.182n"
7
"003,Laura,Eglington,elinton@python.co.jp,26yearsold,36.55.173.63n"
8
"004,Timo,Baum,timobaum@tennis.co.cn,22yearsold,121.121.110.10")
9
10
matches = re.finditer(regex, your_string, re.MULTILINE)
11
12
for match in matches:
13
result = match.group(1)
14
print(result)
15