Python
- 3 ответа
- 0 вопросов
1
Вклад в тег
import re
raw_string = 'Jul 10 10:09:08 srv24-s-st postfix/qmgr[3043]: 25E6CDF04F4: from=<testmail@email.ru>, size=617951, nrcpt=1 (queue active)'
email_pattern = re.compile(r'[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+')
email_from_raw_string = email_pattern.search(raw_string).group()
new_string = email_pattern.sub('test@mail.ru', raw_string)
print(email_from_raw_string)
print(new_string)