OWASP Validation Regex Repository | OWASP Foundation
OWASP Validation Regex Repository
Author:
Weilin Zhong, Achim
Contributor(s):
Delink, Christopher Hendrix, Wichers, Jmanico, Thomas Herzog, Duccio Fabbri, EPaul, kingthorin
Note: These Regexs are examples and not built for a particular Regex
engine. However, the PCRE syntax is mainly used. In particular, this
means that character classes do not contain meta characters which
need to be escaped, except the
and
character, where it is
assumed that a
needs not to be escaped only when it is the last
character in a character class. The character class supports
shortcut notations for other character classes like
\s
or
\w
which should not be used as they depend on the LOCALE environment
setting in most systems.
Please carefully test the regex in your regex engine.
url
A valid URL per the URL spec.
IP
A valid IP Address
e-mail
A valid e-mail address
safetext
Lower and upper case letters and all digits
date
Date in US format with support for leap years
creditcard
A valid credit card number
password
4 to 8 character password requiring numbers and both lowercase and uppercase letters
complexpassword
,;:_=?*+#."&§%°()\|\[\]\-\$\^\@\/]{12,128}$]]>
12 to 128 character password requiring at least 3 out 4 (uppercase and lowercase letters, numbers and special characters) and no more than 2 equal characters in a row
English_digitwords
The English words representing the digits 0 to 9
English_daywords
English 2 character abbreviations for the days of the week
English_monthwords
English 3 character abbreviations for the months
French_digitwords
The French words representing the digits 0 to 9
German_digitwords
The German words representing the digits 0 to 9
Spanish_digitwords
The Spanish words representing the digits 0 to 9
UK_NINO
United Kingdom National Insurance Number (which is not a number!)
US_zip
US zip code with optional dash-four
US_phone
US phone number with or without dashes
US_state
2 letter U.S. state abbreviations
US_ssn
9 digit U.S. social security number with dashes
Other Regex References
Regex101
: An online tool for building/testing regular expressions.
RegexPlanet
: An online tool for building/testing regular expressions (11+ languages/engines).
Regex Library Site
: A site that has a HUGE library of regular expressions and other regex resources
Regex Tutorial Site
: A site with lots of tutorials on writing Regexs and numerous examples
Watch
Star
The OWASP
Foundation
works to improve the security of software through its community-led open source software projects,
hundreds of chapters worldwide, tens of thousands of members, and by hosting local and global conferences.
Upcoming OWASP Global Events
US