Regular expression for email masking
问题 I am trying to write a regular expression to mask an email address. Example below. input: john.doe@example.en.com output: j*******@e*********.com I have tried the following but I just can't seem to get it working correctly. regex: (?<=.).(?=[^@]\*?@) output:j*******@example.en.com regex: (?<=.).(?=[^@]\*?)(?=[^\.]\*?\.) output:j******************.com Any help would be appreciated. demo 回答1: Update with various masking email solutions foo@bar.com ⇒ f**@b**.com (current question) - s.replaceAll