OWASP Validation Regex Repository

 

url <![CDATA[^((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,]blank:)?$]]>

IP  	 <![CDATA[^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$]]>

e-mail <![CDATA[^[\w\-\+\&\*]+(?:\.[\w\-\_\+\&\*]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$]]>

safetext <![CDATA[^[a-zA-Z0-9\s.\-]+$]]> Lower and upper case letters and all digits

date <![CDATA[^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$]]> Date in US format with support for leap years

creditcard <![CDATA[^((4\d{3})|(5[1-5]\d{2})|(6011)|(7\d{3}))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$]]>

password <![CDATA[^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$]]> 4 to 8 character password requiring numbers and both lowercase and uppercase letters

English_digitwords <![CDATA[^(zero|one|two|three|four|five|six|seven|eight|nine)$]]> The English words representing the digits 0 to 9

English_daywords <![CDATA[^(Mo|Tu|We|Th|Fr|Sa|Su)$]]> English 23 character abbreviations for the days of the week

English_monthwords <![CDATA[^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$]]> English 3 character abbreviations for the months

French_digitwords <![CDATA[^(z[eé]ro|un|deux|trois|quatre|cinq|six|sept|huit|neuf)$]]> The Frensh words representing the digits 0 to 9

German_digitwords <![CDATA[^(null|eins|zwei|drei|vier|f(ue|ü)nf|sechs|sieben|acht|neun)$]]> The German words representing the digits 0 to 9

Spanish_digitwords <![CDATA[^(cero|uno|dos|tres|cuatro|cinco|seis|siete|ocho|nueve)$]]> The Spanish words representing the digits 0 to 9

US_zip <![CDATA[^\d{5}(-\d{4})?$]]> US zip code with optional dash-four

US_phone <![CDATA[^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$]]> US phone number with or without dashes

US_state <![CDATA[^(AE|AL|AK|AP|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MP|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY)$]]> Two letter state abbreviations

US_ssn <![CDATA[^\d{3}-\d{2}-\d{4}$]]> 9 digit social security number with dashes

=Other Regex References=

Regex Library Site

http://regexlib.com/: A site that has a HUGE library of regular expressions and other regex resources

Regex Construction Tool

http://www.ultrapico.com/Expresso.htm: A free regex construction tool