import re s = 'email@mail.ru' print(re.sub('(.).*@', r'\1***@', s))print(re.sub('.(@.*)|(?!^).', r'*\1', s))
Standard input is empty
e***@mail.ru e****@mail.ru
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!