Skip to content

Instantly share code, notes, and snippets.

@chaoswey
Created December 26, 2018 01:53
Show Gist options
  • Save chaoswey/4282a041a6ad83ab02a0f47227157cbe to your computer and use it in GitHub Desktop.
Save chaoswey/4282a041a6ad83ab02a0f47227157cbe to your computer and use it in GitHub Desktop.
密碼常用的正則表示式
至少八個字符,至少一個字母和一個數字:
"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
至少八個字符,至少一個字母,一個數字和一個特殊字符:
"^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$"
至少八個字符,至少一個大寫字母,一個小寫字母和一個數字:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
至少八個字符,至少一個大寫字母,一個小寫字母,一個數字和一個特殊字符:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$"
最少8個字符和最多10個字符,至少一個大寫字母,一個小寫字母,一個數字和一個特殊字符:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,10}$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment