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

常用的正規表示式(Regular Expression) #12

Open
mangreen opened this issue Apr 8, 2015 · 0 comments
Open

常用的正規表示式(Regular Expression) #12

mangreen opened this issue Apr 8, 2015 · 0 comments

Comments

@mangreen
Copy link
Owner

mangreen commented Apr 8, 2015

//信用卡檢查
/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|622((12[6-9]|1[3-9][0-9])|([2-8][0-9][0-9])|(9(([0-1][0-9])|(2[0-5]))))[0-9]{10}|64[4-9][0-9]{13}|65[0-9]{14}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})*$/

//檢查字串只能有文字與數字
/^[a-zA-Z0-9]*$/

//檢查字串只能有文字
/^[a-zA-Z]*$/

//檢查字串只能有數字
/^[0-9]*$/

//檢查日期型態 (MM/DD/YYYY)
/^((0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2})*$/

//檢查日期型態 (YYYY/MM/DD)
 #^((19|20)?[0-9]{2}[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01]))*$#

//簡易的Email檢查
/^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})*$/

//檢查IP位址
/^((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$/

//檢查密碼:密碼長度必須有8~16碼,並且包含至少一個小寫字母與一個大寫字母和一個數字
/^(?=^.{8,16}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.*$/

//檢查密碼:密碼長度必須有8~16碼,並且包含至少一個大或小寫字母和一個數字
/^(?=.*\d)(?=.*[a-zA-Z]).{8,16}$/

//檢查網址
/^(((http|https|ftp):\/\/)?([[a-zA-Z0-9]\-\.])+(\.)([[a-zA-Z0-9]]){2,4}([[a-zA-Z0-9]\/+=%&_\.~?\-]*))*$/
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