Wednesday, July 6, 2011

HTML5Pattern - Sweet Regex

HTML5Pattern should be a source of regularly used Inputs-Patterns. If you know a better pattern of the existing patterns or if you know a new pattern, then please leave a comment. Thank you!

Support: Firefox 4b7 & Chrome 6 & Opera 9 & Safari 5.0.3

DescriptionPatternTestfieldSource
Credit Card Number[0-9]{13,16}by dipser
Diners Club Card^([30|36|38]{2})([0-9]{12})$by regexlib.com
ICQ UIN([1-9]) (?:-?\d){4,}by dipser & Flobse
Alpha-Numeric^[a-zA-Z0-9] $by dipser
Domain like "abc.de"^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.) [a-zA-Z]{2,6}$by Unknown
IPv4 Address((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$by Rasmus Fløe
IPv6 Address((^|:)([0-9a-fA-F]{0,4})){1,8}$by Rasmus Fløe & dipser
Username with 2-20 chars (format: string string|number)^[a-zA-Z][a-zA-Z0-9-_\.]{1,20}$by dipser
Password (UpperCase, LowerCase and Number)^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$by imar.spaanjaars.com
Password (UpperCase, LowerCase, Number/SpecialChar and min 8 Chars)(?=^.{8,}$)((?=.*\d)|(?=.*\W ))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$by imar.spaanjaars.com
American Postal Code (format is nnnnn or nnnnn-nnnn)(\d{5}([\-]\d{4})?)by useragentman.com
Canadian Postal Code (Format: A0A 0A0)^([A-Za-z][0-9][A-Za-z] [0-9][A-Za-z][0-9])$by Patrick Denny & dipser
Australia Postal Code (Format: nnnn)^[0-9]{4}$by dipser
Hungarian Postal Code (Format: nnnn)^[0-9]{4}$by Ákos Nikházy
German Postal Code (Format: nnnnn)^[0-9]{5}$by dipser
Swedish Postal Code (Format: nnnnn)^[0-9]{5}$by Joakim
Japanese Postal Code (Format: nnn-nnnn)^\d{3}-\d{4}$by Daniel Davis
Spanish Postal Code (Format: 01xxx to 50xxx)((0[1-9]|5[0-2])|[1-4][0-9])[0-9]{3}by Santi Martin
Dutch Postal Code (Format: 1234 aa)^[1-9][0-9]{3}\s?[a-zA-Z]{2}$by Jos Krause & wnas
Date (Format: YYYY-MM-DD)[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])by dipser
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))by Patrick Denny
Date (Format: MM/DD/YYYY)(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\dby ericleads.com
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}by Patrick Denny
Latitude or Longitude-?\d{1,3}\.\d by the-art-of-web.com
Price (Format: 1.00)\d (\.\d{2})?by the-art-of-web.com
Price (Format: 1,00)\d (,\d{2})?by the-art-of-web.com
Phone Number (Format: 99(99)9999-9999)[\ ]\d{2}[\(]\d{2}[\)]\d{4}[\-]\d{4}by José Lucas
Integers with or without decimals (Format: 9 or 9.9)\-?\d (\.\d{0,})?by Kenny


Make your own pattern:

Please enable JavaScript to view the comments powered by Disqus. blog comments powered by Disqus

Posted via email from Color and Voice

No comments:

Post a Comment