We’re preparing your current view and syncing the latest data.
Given a string representing either an email address or a phone number, mask personal information by applying specific masking rules. For emails, mask all characters between the first and last character of the local part with 5 asterisks ('*'), and convert the entire email to lowercase. For phone numbers, remove all non-digit characters and mask all but the last 4 digits, with country code masking as specified.
A single string s that is either a valid email address or a phone number containing digits, letters, '+', '-', '(', ')', and spaces.
A single string representing the masked version of the input personal information.
The input email is guaranteed to be valid and contain exactly one '@'. The phone number contains between 10 and 13 digits.
Example 1
Input
"LeetCode@LeetCode.com"
Output
"l*****e@leetcode.com"
Explanation
In the email, the local part 'LeetCode' is masked between the first and last character, replacing 'eetcod' with 5 asterisks and converted to lowercase.
Example 2
Input
"1(234)567-890"
Output
"***-***-7890"
Explanation
The phone number has 10 digits so no country code, mask everything except last 4 digits.
Example 3
Input
"+86-(10)12345678"
Output
"+**-***-***-5678"
Explanation
The phone number has country code length 2 ('86'), so mask as '+**-' plus the masked digits.