--- tags: Note --- # 正規表達式 ### 信箱 - 目前使用 `/^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/` - 範例 --- ### 密碼 `"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,16}$" ` 最少八個字符,至少一個大寫字母,一個小寫字母和一個數字,最多16個 --- ### 地址 - 目前使用 `(?<city>\D+[縣市])(?<district>\D+?(市區|鎮區|鎮市|[鄉鎮市區]))(?<others>.+)` - 範例 - `台北市信義區市府路` (市+區+隨) --- ### 信用卡 - 目前使用 `/^(\d{4}-?\d{4}-?\d{4}-?\d{4})$/` - 範例 - `1234-5678-1234-5678` - `1234567812345678` --- ## 參考資料 - [常用正規表達式(未檢驗過)](https://ian.partners-studio.com/2016/12/04/javascript-regular-expression/) - [測試網站 —— regex101](https://regex101.com/r/p2wSQI/1) - [使用 Regex 來 Parse 台灣的地址](https://dotblogs.com.tw/hatelove/2012/06/05/parse-taiwan-address-with-regex)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.