In [ ]:
import re
In [ ]:
texto = 'um exemplo palavra:python!!'
In [ ]:
match = re.search('python', texto)
In [ ]:
print(match)
In [ ]:
if match:
print('encontrou: ' + match.group())
else:
print('não encontrou')
In [ ]:
texto = "GGATCGGAGCGGATGCC"
In [ ]:
match = re.search(r'a[tg]c', texto, re.IGNORECASE)
In [ ]:
if match:
print('encontrou: ' + match.group())
else:
print('não encontrou')
In [ ]:
match
In [ ]:
texto = 'teste-teste@gmail-teste.com'
In [ ]:
match = re.search(r'([\w.-]+)@([\w.-]+)', texto)
In [ ]:
if match:
print('email:', match.group())
print('login:', match.group(1))
print('dominio:', match.group(2))
else:
print('não encontrou')
In [ ]:
texto = 'teste teste@gmail.com teste123 teste-123@gmail.com, python 123@123.com'
In [ ]:
emails = re.findall(r'[\w.-]+@[\w.-]+', texto)
In [ ]:
for email in emails:
print(email)
In [ ]:
arquivo = open('er-emails.txt', 'r')
In [ ]:
In [ ]:
In [ ]:
Considere o arquivo er-dados.txt. Esse arquivo contêm diversas strings no formato:
Tue Feb 15 10:39:54 2028::xjkmxk@cltllsls.com
Por fim, imprima os valores no seguinte formato:
1 - email@completo.com | login | dominio | dia/mês/ano | hora:minuto
É importante pensar em como deve-se carregar o arquivo. Repare que o horário no arquivo considera os segundos e a impressão final não.
In [ ]:
# Parte 1
In [ ]:
# Parte 2
In [ ]:
# Parte 3a - anos
In [ ]:
# Parte 3b - meses
In [ ]:
# Parte 3c - dias
In [ ]:
# Parte 3d - horário
In [ ]:
# Parte 4
In [ ]: