Community Patterns

Community Library Entry

4

Regular Expression
Created·2016-02-03 12:38
Flavor·PCRE (Legacy)

/
(?<=.).(?=[^@]*?.@)|(?:(?<=@.)|(?!^)\G(?=[^@]*$))(.)(?=.*\.)|(?:(?<=\.)(?=[^.]+$)|(?!^)\G(?=[^@.]*$))[^.](?!$)
/
gm
Open regex in editor

Description

Replaces second to last but one characters in email with asterisks (@ and last . are protected): john.travolta@gmail.com > j***********a@g****.**m

Submitted by Wiktor Stribiżew