2023-08-26 10:19:00 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
def mask_number(number):
|
|
|
|
number_str = str(number)
|
2024-05-04 14:47:44 +00:00
|
|
|
masked_number = None
|
2024-07-04 11:09:48 +00:00
|
|
|
if len(number_str) == 8:
|
|
|
|
masked_number = re.sub(r"(\d{2})(\d{3})(\d{3})", r"\1***\3", number_str)
|
2023-08-26 10:19:00 +00:00
|
|
|
if len(number_str) == 9:
|
|
|
|
masked_number = re.sub(r"(\d{2})(\d{4})(\d{3})", r"\1****\3", number_str)
|
2024-05-04 14:47:44 +00:00
|
|
|
if len(number_str) == 10:
|
|
|
|
masked_number = re.sub(r"(\d{3})(\d{4})(\d{3})", r"\1****\3", number_str)
|
|
|
|
if masked_number:
|
2023-08-26 10:19:00 +00:00
|
|
|
return masked_number
|
|
|
|
return "Invalid input"
|