1234567891011121314151617181920212223 |
- package regular
- import "regexp"
- func MaskPhoneNumber(phoneNumber string) string {
- if len(phoneNumber) == 0 {
- return ""
- }
-
- re := regexp.MustCompile(`(\d{3})\d{4}(\d{4})`)
- return re.ReplaceAllString(phoneNumber, "$1****$2")
- }
- func MaskIDNumber(idNumber string) string {
- if len(idNumber) == 0 {
- return ""
- }
-
- re := regexp.MustCompile(`(\d{3})\d+(\d{4})`)
- return re.ReplaceAllString(idNumber, "$1********$2")
- }
|