I want to mask the email id as follows :
Input | Output
[email protected] : qw**[email protected]
[email protected] : he******[email protected]
[email protected] : st*********[email protected]
[email protected] : ab*[email protected]
[email protected] : a**[email protected]
[email protected] : a*[email protected]
[email protected] : a*@gmail.com
Max 2 characters at both the extremes if available, minimum 1 character at each end are to be displayed or just mask the last character.
The string has to be atleast 2 characters in length ([email protected]).
I referred some of the solutions provided, but was not able to achieve the second and third scenario using those. Is there a possibility to find a fix ? I'm not well versed with regex, so I'm not sure which way to go ahead.
references : masking of email address in java
How to i mask all string characters except for the last 4 characters in Java using parameters?