You are given a personal information string s, which represents either an email address or a phone number. Return the masked personal information according to the following rules:
Email address:
An email address consists of a local name, an '@' symbol, and a domain name. To mask an email:
Convert all uppercase letters in both the local name and the domain name to lowercase.
Replace all characters between the first and last character of the local name with "*****".
Phone number:
A phone number consists of '(', ')', '-', and '+'. The last
Remove all separation characters, keeping only the digits.
The local number is masked as "***-***-XXXX", where "XXXX" represents the last
If a country code is present ("+*-", "+**-", or "+***-" respectively to the masked local number.
Constraints:
s is either a valid email address or a phone number.
If s is an email:
s.length
s consists of uppercase and lowercase English letters, exactly one '@' symbol, and exactly one '.' symbol.
If s is a phone number:
s.length
s consists of digits, spaces, and the symbols '(', ')', '-', and '+'.
You are given a personal information string s, which represents either an email address or a phone number. Return the masked personal information according to the following rules:
Email address:
An email address consists of a local name, an '@' symbol, and a domain name. To mask an email:
Convert all uppercase letters in both the local name and the domain name to lowercase.
Replace all characters between the first and last character of the local name with "*****".
Phone number:
A phone number consists of '(', ')', '-', and '+'. The last
Remove all separation characters, keeping only the digits.
The local number is masked as "***-***-XXXX", where "XXXX" represents the last
If a country code is present ("+*-", "+**-", or "+***-" respectively to the masked local number.
Constraints:
s is either a valid email address or a phone number.
If s is an email:
s.length
s consists of uppercase and lowercase English letters, exactly one '@' symbol, and exactly one '.' symbol.
If s is a phone number:
s.length
s consists of digits, spaces, and the symbols '(', ')', '-', and '+'.