Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

号码脱敏 #45

Open
hans000 opened this issue Jul 8, 2023 · 0 comments
Open

号码脱敏 #45

hans000 opened this issue Jul 8, 2023 · 0 comments
Labels
js javascript regexp 正则

Comments

@hans000
Copy link
Owner

hans000 commented Jul 8, 2023

问题描述

对电话号码的中间4位做脱敏处理,例如:1881234578 -> 188****5678

解决方案

function desensitize(phoneNumber) {
    return phoneNumber.replace(/^(\d{3}).+(\d{4})$/, '$1****$2')
}

参考链接

列出方案的具体原理

@hans000 hans000 added js javascript regexp 正则 labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js javascript regexp 正则
Projects
None yet
Development

No branches or pull requests

1 participant