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

「优化」座机正则表达式存在冗余 #319

Open
condorheroblog opened this issue Jul 21, 2024 · 0 comments
Open

「优化」座机正则表达式存在冗余 #319

condorheroblog opened this issue Jul 21, 2024 · 0 comments

Comments

@condorheroblog
Copy link

原始正则:

/^(?:(?:\d{3}-)?\d{8}|^(?:\d{4}-)?\d{7,8})(?:-\d+)?$/

image

正则中的第二个定位符(^)是不必要的,可以删除,保留一个即可:

image

/^(?:(?:\d{3}-)?\d{8}|(?:\d{4}-)?\d{7,8})(?:-\d+)?$/

通过 regexp/no-useless-assertions 检查发现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant