<reponame>vhn0912/python-snippets
import re

s = '<EMAIL>, <EMAIL>, <EMAIL>'

result = re.findall(r'[a-z]+@[a-z]+\.[a-z]+', s)
print(result)
# ['<EMAIL>', '<EMAIL>', '<EMAIL>']

print(len(result))
# 3

result = re.findall(r'([a-z]+)@([a-z]+)\.([a-z]+)', s)
print(result)
# [('aaa', 'xxx', 'com'), ('bbb', 'yyy', 'com'), ('ccc', 'zzz', 'net')]

result = re.findall(r'(([a-z]+)@([a-z]+)\.([a-z]+))', s)
print(result)
# [('<EMAIL>', 'aaa', 'xxx', 'com'), ('<EMAIL>', 'bbb', 'yyy', 'com'), ('<EMAIL>', 'ccc', 'zzz', 'net')]

result = re.findall('[0-9]+', s)
print(result)
# []

s = '<EMAIL>, <EMAIL>, <EMAIL>'

result = re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)
print(result)
# <callable_iterator object at 0x10b0efa90>

print(type(result))
# <class 'callable_iterator'>

for m in result:
    print(m)
# <re.Match object; span=(0, 11), match='<EMAIL>'>
# <re.Match object; span=(13, 24), match='<EMAIL>'>
# <re.Match object; span=(26, 37), match='<EMAIL>'>

l = list(re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s))
print(l)
# [<re.Match object; span=(0, 11), match='<EMAIL>'>, <re.Match object; span=(13, 24), match='<EMAIL>'>, <re.Match object; span=(26, 37), match='<EMAIL>'>]

print(l[0])
# <re.Match object; span=(0, 11), match='<EMAIL>'>

print(type(l[0]))
# <class 're.Match'>

print(l[0].span())
# (0, 11)

print([m.span() for m in re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)])
# [(0, 11), (13, 24), (26, 37)]

result = re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)

for m in result:
    print(m)
# <re.Match object; span=(0, 11), match='<EMAIL>'>
# <re.Match object; span=(13, 24), match='<EMAIL>'>
# <re.Match object; span=(26, 37), match='<EMAIL>'>

print(list(result))
# []

import re

s = '<EMAIL>, <EMAIL>, <EMAIL>'

result = re.findall(r'[a-z]+@[a-z]+\.[a-z]+', s)
print(result)
# ['<EMAIL>', '<EMAIL>', '<EMAIL>']

print(len(result))
# 3

result = re.findall(r'([a-z]+)@([a-z]+)\.([a-z]+)', s)
print(result)
# [('aaa', 'xxx', 'com'), ('bbb', 'yyy', 'com'), ('ccc', 'zzz', 'net')]

result = re.findall(r'(([a-z]+)@([a-z]+)\.([a-z]+))', s)
print(result)
# [('<EMAIL>', 'aaa', 'xxx', 'com'), ('<EMAIL>', 'bbb', 'yyy', 'com'), ('<EMAIL>', 'ccc', 'zzz', 'net')]

result = re.findall('[0-9]+', s)
print(result)
# []

s = '<EMAIL>, <EMAIL>, <EMAIL>'

result = re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)
print(result)
# <callable_iterator object at 0x10b0efa90>

print(type(result))
# <class 'callable_iterator'>

for m in result:
    print(m)
# <re.Match object; span=(0, 11), match='<EMAIL>'>
# <re.Match object; span=(13, 24), match='<EMAIL>'>
# <re.Match object; span=(26, 37), match='<EMAIL>'>

l = list(re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s))
print(l)
# [<re.Match object; span=(0, 11), match='<EMAIL>'>, <re.Match object; span=(13, 24), match='<EMAIL>'>, <re.Match object; span=(26, 37), match='<EMAIL>'>]

print(l[0])
# <re.Match object; span=(0, 11), match='<EMAIL>'>

print(type(l[0]))
# <class 're.Match'>

print(l[0].span())
# (0, 11)

print([m.span() for m in re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)])
# [(0, 11), (13, 24), (26, 37)]

result = re.finditer(r'[a-z]+@[a-z]+\.[a-z]+', s)

for m in result:
    print(m)
# <re.Match object; span=(0, 11), match='<EMAIL>'>
# <re.Match object; span=(13, 24), match='<EMAIL>'>
# <re.Match object; span=(26, 37), match='<EMAIL>'>

print(list(result))
# []
# ['<EMAIL>', '<EMAIL>', '<EMAIL>'] # 3 # [('aaa', 'xxx', 'com'), ('bbb', 'yyy', 'com'), ('ccc', 'zzz', 'net')] # [('<EMAIL>', 'aaa', 'xxx', 'com'), ('<EMAIL>', 'bbb', 'yyy', 'com'), ('<EMAIL>', 'ccc', 'zzz', 'net')] # [] # <callable_iterator object at 0x10b0efa90> # <class 'callable_iterator'> # <re.Match object; span=(0, 11), match='<EMAIL>'> # <re.Match object; span=(13, 24), match='<EMAIL>'> # <re.Match object; span=(26, 37), match='<EMAIL>'> # [<re.Match object; span=(0, 11), match='<EMAIL>'>, <re.Match object; span=(13, 24), match='<EMAIL>'>, <re.Match object; span=(26, 37), match='<EMAIL>'>] # <re.Match object; span=(0, 11), match='<EMAIL>'> # <class 're.Match'> # (0, 11) # [(0, 11), (13, 24), (26, 37)] # <re.Match object; span=(0, 11), match='<EMAIL>'> # <re.Match object; span=(13, 24), match='<EMAIL>'> # <re.Match object; span=(26, 37), match='<EMAIL>'> # []