We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1b8371 commit e38e673Copy full SHA for e38e673
utls.py
@@ -1,15 +1,19 @@
1
from itertools import tee
2
-
+import re
3
4
def scrap(wrds):
5
- s = set()
+ if isinstance(wrds, str):
6
+ wrds = wrds.split(' ')
7
+ data = set()
8
+ pattern = re.compile(r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+')
9
for wrd in wrds:
- splited_wrd = wrd.split(' ')
- for i in range(len(splited_wrd)):
- wrds_indexed = splited_wrd[i]
10
- if ('@' in wrds_indexed and '.' in wrds_indexed) and (len(wrds_indexed) > 7):
11
- s.add(wrds_indexed)
12
- yield from s
+ matches = pattern.search(str(wrd))
+ try:
+ data.add(matches.group(0))
13
+ except AttributeError:
14
+ pass
15
+ yield from data
16
+
17
18
19
def files():
0 commit comments