Date Format (m/d/y) ^([\d]|1[0,1,2])/([0-9]|[0,1,2][0-9]|3[0,1])/\d{4}$ 12/21/2005
Decimal Number ^\d*[0-9](\.\d*[0-9])?$ 234.342
Document Filenames ^[a-zA-Z0-9-_\.]+\.(pdf|txt|doc|csv)$ world-domination.pdf
E-mail Address ^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*(.){1}[a-zA-Z]{2,4})+$
HTML Color Codes ^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$ #00ccff
Image Filenames ^[a-zA-Z0-9-_\.]+\.(jpg|gif|png)$ new-pic_company.jpg
IP Address ^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$ 192.168.0.1
Multimedia Filenames ^[a-zA-Z0-9-_\.]+\.(swf|mov|wma|mpg|mp3|wav)$ company-presentation.swf
MySQL Date Format ^\d{4}-(0[0-9]|1[0,1,2])-([0,1,2][0-9]|3[0,1])$ 2005-09-02
Phone Number ^[2-9]\d{2}-\d{3}-\d{4}$ 250-555-4542
Postal Code (CAD) ^([A-Z][0-9]){3}$ V2B2S3
Time Format (HH:MM) ^([0-1][0-9]|[2][0-3])(:([0-5][0-9])){1,2}$ 12:29
URL ^(http[s]?://|ftp://)?(www\.)?[a-zA-Z0-9-\.]+\.(com|org|net|mil|edu|ca|co.uk|com.au|gov)$
Versatile Phone Number ^(([0-9]{1})*[- .(]*([0-9a-zA-Z]{3})*[- .)]*[0-9a-zA-Z]{3}[- .]*[0-9a-zA-Z]{4})+$ 1.245.532.3422
Credit Card Number [0-9]{13,16}
Diners Club Card ^([30|36|38]{2})([0-9]{12})$
ICQ UIN ([1-9])+(?:-?\d){4,}
Alpha-Numeric ^[a-zA-Z0-9]+$
Domain like "abc.de" ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$
IPv4 Address ((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$
IPv6 Address ((^|:)([0-9a-fA-F]{0,4})){1,8}$
Username with 2-20 chars (format: string+string|number) ^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$
Password (UpperCase, LowerCase and Number) ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$
Password (UpperCase, LowerCase, Number/SpecialChar and min 8 Chars) (?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
American Postal Code (format is nnnnn or nnnnn-nnnn) (\d{5}([\-]\d{4})?)
Canadian Postal Code (Format: A0A 0A0) ^([A-Za-z][0-9][A-Za-z] [0-9][A-Za-z][0-9])$
Australia Postal Code (Format: nnnn) ^[0-9]{4}$
Austrian Postal Code (Format: nnnn) ^[0-9]{4}$
Hungarian Postal Code (Format: nnnn) ^[0-9]{4}$
German Postal Code (Format: nnnnn) ^[0-9]{5}$
Swedish Postal Code (Format: nnnnn) ^[0-9]{5}$
Japanese Postal Code (Format: nnn-nnnn) ^\d{3}-\d{4}$
Spanish Postal Code (Format: 01xxx to 50xxx) ((0[1-9]|5[0-2])|[1-4][0-9])[0-9]{3}
Dutch Postal Code (Format: 1234 aa) ^[1-9][0-9]{3}\s?[a-zA-Z]{2}$
Date (Format: YYYY-MM-DD) [0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])
Full Date Validation (YYYY-MM-DD) (?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))
Date (Format: MM/DD/YYYY) (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
Full date validation (MM/DD/YYYY) (?:(?:0[1-9]|1[0-2])[\/\\-. ]?(?:0[1-9]|[12][0-9])|(?:(?:0[13-9]|1[0-2])[\/\\-. ]?30)|(?:(?:0[13578]|1[02])[\/\\-. ]?31))[\/\\-. ]?(?:19|20)[0-9]{2}
Latitude or Longitude -?\d{1,3}\.\d+
Price (Format: 1.00) \d+(\.\d{2})?
Price (Format: 1,00) \d+(,\d{2})?
Phone Number (Format: +99(99)9999-9999) [\+]\d{2}[\(]\d{2}[\)]\d{4}[\-]\d{4}
Integers with or without decimals (Format: 9 or 9.9) \-?\d+(\.\d{0,})?
UUID ^[0-9A-Fa-f]{8}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{12}$
'Code Snippets > javascript' 카테고리의 다른 글
모바일 기기 구분 (0) | 2018.05.02 |
---|---|
소수점 반올림하기 (0) | 2014.07.30 |