Friday, October 14, 2011

validation expression


                                                                     

Here are a few more common ranges that you may want to match:

000..255: ^([01][0-9][0-9]|2[0-4][0-9]|25[0-5])$
0 or 000..255: ^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$
0 or 000..127: ^(0?[0-9]?[0-9]|1[0-1][0-9]|12[0-7])$
0..999: ^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$
000..999: ^[0-9]{3}$
0 or 000..999: ^[0-9]{1,3}$
1..999: ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$
001..999: ^(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9])$
1 or 001..999: ^(0{0,2}[1-9]|0?[1-9][0-9]|[1-9][0-9][0-9])$
0 or 00..59: ^[0-5]?[0-9]$
0 or 000..366: ^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-6])$

mm/dd/yyyy c : (0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d
dd-mm-yyyy : (0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d

Matches numbers 0 through 99.9 Allows only one preceding zero and does not require the decimal point
^([1-9]{0,1})([0-9]{1})(\.[0-9])?$

currency format that allows optional $, optional "-"(MinusSignNegative) OR "()" (ParenNegative) but not both, optional cents, and optional commas separating thousands. Minus sign can be before or after $, but parens must be outside the $. UPDATED: now fails to match a "$" without any further numbers
^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$
=================================================================================================

Expression ^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$
Description Many currency expresssions allow leading zeros, thus $01.40 passes thru them. This expression kills them, except for 0 in the one's column. Works with or without commas and/or dollar sign. Decimals not mandatory, unless no zero in ones column and decimal point is placed. Allows $0.00 and .0 Keywords: money dollar currency
Matches $1,234.50 | $0.70 | .7
Non-Matches $0,123.50 | $00.5

=======================================================================================
Title Test Details Pattern Title
Expression ^([1-9]{0,1})([0-9]{1})(\.[0-9])?$
Description Matches numbers 0 through 99.9 Allows only one preceding zero and does not require the decimal point
Matches 1 | 1.1 | 0.1
Non-Matches 01 | 01.1 | 0.10
=============================================================================================
Expression ^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$
Description currency format that allows optional $, optional "-"(MinusSignNegative) OR "()" (ParenNegative) but not both, optional cents, and optional commas separating thousands. Minus sign can be before or after $, but parens must be outside the $. UPDATED: now fails to match a "$" without any further numbers
Matches ($4,000.00) | -$4000.00 | -$400.00
Non-Matches 4,00.000 | abc | $
============================================================================
Expression ^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$
Description Many currency expresssions allow leading zeros, thus $01.40 passes thru them. This expression kills them, except for 0 in the one's column. Works with or without commas and/or dollar sign. Decimals not mandatory, unless no zero in ones column and decimal point is placed. Allows $0.00 and .0 Keywords: money dollar currency
Matches $1,234.50 | $0.70 | .7
=====================================================================
Expression ^-?[0-9]{0,2}(\.[0-9]{1,2})?$|^-?(100)(\.[0]{1,2})?$
Description Matches a negative or positive percentage between 0 and 100 (inclusive). Accepts up to 2 decimal places.
Matches 12.34 | 100.00 | -2.1
Non-Matches 101.1 | 10.123 | 100.10
======================================================================
Expression ^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$
Description This matches floating point expression in a more rigorous way - accepts both exponent as well as non exponent notations.
Matches 123 | -123.35 | -123.35e-2
Non-Matches abc | 123.32e | 123.32.3
=======================================================================
Expression ^\$?\d+(\.(\d{2}))?$
Description To evaluate an amount with or without a dollar sign where the cents are optional.
Matches $2.43 | 2.02 | $2112
Non-Matches 2.1 | $.14 | $2,222.12
===========================================================================
Expression ^(?!\u00a2) #Don't allow cent symbol \p{Sc}? #optional unicode currency symbols (?!0,?\d) #don't allow leading zero if 1 or more unit (\d{1,3} # 1 to 3 digits (\,\d{3})* # if the is a comma it must be followed by 3 digits |(\d+)) # more than 3 digit with no comma separator (\.\d{2})?$ # option cents
Description This regex validates Currency. The base monetary unit (ex. US dollar) followed by option two digit cent denomination. Base unit can't have leading zero. Comma's are optional on base units. Note: Your regex engine must support the \p character class to use this. For example this will work in .net but not javascript which doesn't support \p Also the ¢ is removed from the match by force. Any other cent symbol would need to be added to the exclude to not match.
Matches $1,501.13 | £215 | €4.93
Non-Matches 01.00 | $.00 | ¢50
==========================================================
Expression ^\d{0,2}(\.\d{1,2})?$
Description This regular expression validates that the data entered is a number with a maximum of two integers and two decimals and a minimum of one integer or one decimal.
Matches 99.99 | 99 | .99
Non-Matches 999.999 | 999 | .999
===============================================================
Expression ^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$
Description This is permit all decimal number, exclude all alphanumeric caracter
Matches 123456.123456 | 123456,123456 | 123456
Non-Matches 123a.123 | 123a,123 | a
=============================================================================
Expression ^(\d|-)?(\d|,)*\.?\d*$
Description Input for Numeric values. Handles negatives, and comma formatted values. Also handles a single decimal point
Matches 5,000 | -5,000 | 100.044
Non-Matches abc | Hundred | 1.3.4
==============================================================================
Expression ^[-+]?[1-9]\d*\.?[0]*$
Description This will check if a number is an integer. Positive integers are all the whole numbers greater than zero: 1, 2, 3, 4, 5, ... . Negative integers are all the opposites of whole numbers: -1, -2, -3,-4, -5, ... . Zero is not a whole number with either a positive or negative value, and is not an interger. Null or Empty values are not intergers.
Matches 10 | -10 | +10.00
Non-Matches 0 | -10.50 | 10.50
================================================================================
Expression ^\$?(\d{1,3},?(\d{3},?)*\d{3}(\.\d{0,2})?|\d{1,3}(\.\d{0,2})?|\.\d{1,2}?)$
Description This expression will validate for US Currency with a wide range of input. Using other exps found on this site, I built this one to fix 2 main problems I was finding: 1-a space or blank entry is non-matching 2-use of .9 in place of .90 will match (this is for those people like me who hate to type and if I put .9 I mean .90 Hope this helps others save a little time. I feel I was pretty thorough in testing, but if you find something wrong, please post it. -Thanks
Matches $1.99 | 1.99 | .99
Non-Matches $10.999 | 100,00.99 | blank
==================================================================================
Expression (^\d{3,5}\,\d{2}$)|(^\d{3,5}$)
Description Expression to validate values to fields Decimal 5,2 or 5 numbers. values >=100,00 <=99999,99 100,00=100 5000,00 = 5000
Matches 100,00 | 100 | 99999,99
Non-Matches 99,99 | 999999 | 1,00
==================================================================================
Expression ^\d+$
Description This is derived from Steven Smith's Integer expression (http://www.regexlib.com/REDetails.aspx?regexp_id=51). The only difference is that this does not accept blanks. Written by Jason N. Gaylord.
Matches 2 | 50 | 0
Non-Matches -15 | 1.2
===================================================================================
Expression ^((\d?)|(([-+]?\d+\.?\d*)|([-+]?\d*\.?\d+))|(([-+]?\d+\.?\d*\,\ ?)*([-+]?\d+\.?\d*))|(([-+]?\d*\.?\d+\,\ ?)*([-+]?\d*\.?\d+))|(([-+]?\d+\.?\d*\,\ ?)*([-+]?\d*\.?\d+))|(([-+]?\d*\.?\d+\,\ ?)*([-+]?\d+\.?\d*)))$
Description This allows a sequence of real numbers to be added, separated by a comma (required) and a space (optional). Based pretty heavily on an expression by Steven Smith on this site.
Matches 8.0 | 8.0,-.38,+8.9 | 8.0, +8.8, 0.09
Non-Matches + | . | a,b, c
====================================================================================
Expression ^[+]?\d*$
Description This re was used for set numbers only! Somente numeros são requeridos!
Matches 0123456789 | 1234 | 1
Non-Matches 1.0?& | a1 | 2a-
=======================================================================================
Expression ^(\d|,)*\.?\d*$
Description Matches Numeric with Commas and a single decimal point. Also matches empty string.
Matches 1,000 | 3,000.05 | 5,000,000
Non-Matches abc | $100,000 | Forty
======================================================================================
Expression ^[-+]?\d*\.?\d*$
Description Matches any floating point numer/numeric string, including optional sign character (+ or -). Also matches empty strings.
Matches 123 | +3.14159 | -3.14159
Non-Matches abc | 3.4.5 | $99.95
=======================================================================================
Expression ^\d{1,7}$
Description Positive Whole number matched from 0 to 9999999. Only 7 digits length is allowed.
Matches 1234567 | 9999999 | 1
Non-Matches 12345678 | 9999.99 | -1234
=======================================================================================
Expression ^\d+(?:\.\d{0,2})?$
Description Matches positive whole numbers with exactly zero or two decimal points if a . is present. Useful for checking currency amounts, such 5 or 5.00 or 5.25.
Matches 1 | 1.23 | 1234.45
Non-Matches a1.34 | 1.23a | a

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Email
=========================================================================================
Expression ^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$
Description It verifies that: - Only letters, numbers and email acceptable symbols (+, _, -, .) are allowed - No two different symbols may follow each other - Cannot begin with a symbol - Ending domain must be at least 2 letters - Supports subdomains - TLD must be between 2 and 6 letters (Ex: .ca, .museum) - Only (-) and (.) symbols are allowed in domain, but not consecutively. Problems: See comments below
Matches g_s+gav@com.com | gav@gav.com | jim@jim.c.dc.ca
Non-Matches gs_.gs@com.com | gav@gav.c | jim@--c.ca

Expression ^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$
Description does not allow IP for domain name : hello@154.145.68.12 does not allow litteral addresses "hello, how are you?"@world.com allows numeric domain names after the last "." minimum 2 letters
Matches he_llo@worl.d.com | hel.l-o@wor-ld.museum | h1ello@123.com
Non-Matches hello@worl_d.com | he&llo@world.co1 | .hello@wor#.co.uk

Expression ^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$
Description Captures Submatches, problem:domainname length can be longer than 64 chars, because every [a-zA-Z0-9][\.\-_] is only countet as one char.
Matches abc@def.gh | a+b_c@d-e_f.gh | abc@def.ghijkl
Non-Matches __@__.__ | -a-@-b-.cd | a--b@c__d.ef

Expression ^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$
Description This accepts RFC 2822 email addresses in the form:<br> blah@blah.com OR<br> Blah &lt;blah@blah.com&gt;<br> <br> RFC 2822 email 'mailbox':<br> mailbox = name-addr | addr-spec<br> name-addr = [display-name] "<" addr-spec ">"<br> addr-spec = local-part "@" domain<br> domain = rfc2821domain | rfc2821domain-literal<br> <br> local-part conforms to RFC 2822.<br> <br> domain is either:<br> An rfc 2821 domain (EXCEPT that the final sub-domain must consist of 2 or more letters only).<br> OR<br> An rfc 2821 address-literal.<br> (Note, no attempt is made to fully validate an IPv6 address-literal.)<br> <br> Notes:<br> This pattern uses (.NET/Perl only?) features named group "(?&lt;name&gt;)" and alternation/IF (?(name)).<br> <br> See <a href="http://regexadvice.com/forums/permalink/26742/26742/ShowThread.aspx#26742">this regexadvice.com thread</a> for more info, including a version that does not use .NET features.<br> <br> RFC 2822 (and 822) do allow embedded comments, whitespace, and newlines within *some* parts of an email address, but this pattern above DOES NOT.<br> <br> RFC 2822 (and 822) allow the domain to be a simple domain with NO ".", but this pattern requires a compound domain at least one "." in the domain name, as per RFC 2821 (4.1.2).<br> <br> RFC 2822 allows/disallows certain whitespace characters in parts of an email address, such as TAB, CR, LF BUT the pattern above does NOT test for these, and assumes that they are not present in the string (on the basis that these characters are hard to enter into an edit box).
Matches name.surname@blah.com | Name Surname <name.surname@blah.com> | "b. blah"@blah.co.nz
Non-Matches name surname@blah.com | name."surname"@blah.com | name@bla-.com

Expression ^[\n &lt;&quot;']*([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)
Description I use this expression to read bounced email addresses returned by the system administrator. The body of the subject should contain the email address somewhere but the location varies. Examples: To: blah.v.blah@blah-blah.net || blah-blah.blah@blah.com || &lt;blah@blah.org&gt;... Deferred: Connection timed out with mail.blah.org. || blah@blah.net 0n 25-12-2004 21:09
Matches blah.v.blah@blah-blah.net | blah-blah.blah@blah.com | .@.
Non-Matches blah@

Expression ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
Description Email validator that adheres directly to the specification for email address naming. It allows for everything from ipaddress and country-code domains, to very rare characters in the username.
Matches asmith@mactec.com | foo12@foo.edu | bob.smith@foo.tv
Non-Matches joe | @foo.com | a@a

Expression ^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$
Description A short and sweet email address validator. Checks that the username starts and ends with an alphanumeric character, allows a few non-repeating 'special characters' (namely -, ., _, +, &amp;) and checks for a sensible domain name (2-6 character TLD required). Some unconventional, yet technically valid, addresses will not be matched, but this is only a simple expression ;-)
Matches test@test.com | nerdy.one@science.museum | ready&amp;set@go.com.au
Non-Matches .test.@test.com | spammer@[203.12.145.68] | bla@bla

Expression ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$
Description regex to validate email address noteworthy: (1) It allows usernames with 1 or 2 alphanum characters, or 3+ chars can have -._ in the middle. username may NOT start/end with -._ or any other non alphanumeric character. (2) It allows heirarchical domain names (e.g. me@really.big.com). Similar -._ placement rules there. (3) It allows 2-9 character alphabetic-only TLDs (that oughta cover museum and adnauseum :&gt;). (4) No IP email addresses though -- I wouldn't Want to accept that kind of address.
Matches e@eee.com | eee@e-e.com | eee@ee.eee.museum
Non-Matches .@eee.com | eee@e-.com | eee@ee.eee.eeeeeeeeee

Expression ^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$
Description Matches e-mail addresses, including some of the newer top-level-domain extensions, such as info, museum, name, etc. Also allows for emails tied directly to IP addresses.
Matches example@example.com | foo@bar.info | blah@127.0.0.1
Non-Matches broken@@example.com | foo@bar.infp | blah@.nospam.biz

Expression ^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*\s+&lt;(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})&gt;$|^(\w[-._\w]*\w@\w[-._\w]*\w\.\w{2,3})$
Description This Works good until we want a multiple email address validator, I am working on it to make it work with the multiple email address, If anyone can work on this part as to validate a multiple email address then that will produce a very good expression, i think the best of this kind. AIM - to Validate Mohit &lt;myadav@yahoo.com&gt;; Rohit &lt;ryadav@yahoo.com&gt;; .........(any number of times)
Matches Mohit &lt;myadav@yahoo.com&gt; | Xon &lt;JON@jon.com&gt; | Xon@something.com
Non-Matches mohit&lt;myadav@yahoo.com&gt; | Xon &lt;JON@jon.com&gt;, tom &lt;jon@jon.com&gt; | Xon@somthing.com,

Expression (?<user>(?:(?:[^ \t\(\)\<\>@,;\:\\\"\.\[\]\r\n]+)|(?:\"(?:(?:[^\"\\\r\n])|(?:\\.))*\"))(?:\.(?:(?:[^ \t\(\)\<\>@,;\:\\\"\.\[\]\r\n]+)|(?:\"(?:(?:[^\"\\\r\n])|(?:\\.))*\")))*)@(?<domain>(?:(?:[^ \t\(\)\<\>@,;\:\\\"\.\[\]\r\n]+)|(?:\[(?:(?:[^\[\]\\\r\n])|(?:\\.))*\]))(?:\.(?:(?:[^ \t\(\)\<\>@,;\:\\\"\.\[\]\r\n]+)|(?:\[(?:(?:[^\[\]\\\r\n])|(?:\\.))*\])))*)
Description Validates email addresses according to the RFC 822 specification. The only exception is the exclusion of control characters, which should be sufficient for human input from a keyboard.
Matches Trais.Gray@domain.biz | "Funny email".notfunny@glxs.biz | ok@[funny domain].co.za
Non-Matches "TravisGray"extra@ domain.biz

Expression ^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$
Description Simple email expression. Doesn't allow numbers in the domain name and doesn't allow for top level domains that are less than 2 or more than 3 letters (which is fine until they allow more). Doesn't handle multiple &quot;.&quot; in the domain (joe@abc.co.uk).
Matches joe@aol.com | ssmith@aspalliance.com | a@b.cc
Non-Matches joe@123aspx.com | joe@web.info | joe@company.co.uk

Expression ^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$
Description this will accept multiple email ids separated only by semi-colons (anyway u can change it).
Matches te_s-t@ts.co.in;te_s-t@ts.co.in;te_s-t@ts.co.in
Non-Matches nospace@between.mailids.in ; only@semi.colons.com

Expression ^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$
Description This pattern allows standard e-mail addresses (e.g. user@domain.com), sub domains (e.g. user@foo.domain.com), the new two- and four-letter domains (e.g. user@domain.tv and user@domain.name) and country codes (e.g. user@foo.com.us). Also, this patter follows the Network Solutions standard length of 67 characters for top-level domains. The reason I allow numbers to be entered in the domain suffix is for future planning. If you do not want numbers to be able to be added as a domain suffix (e.g. user@domain.123), simply delete the last two occurrences of &quot;\d&quot;.
Matches foo@foo.com | foo@foo-foo.com.au | foo@foo.foo.info
Non-Matches foo@.com | foo@foo..com | foo@me@.com

Expression ^[a-z0-9][a-z0-9_\.-]{0,}[a-z0-9]@[a-z0-9][a-z0-9_\.-]{0,}[a-z0-9][\.][a-z0-9]{2,4}$
Description for validate a email, but with this regex it 's possible : a._-z@a_.....____---.com
Matches az@er.tr | a_zer-ty@az.er.ty | 123-456_789.0@1.2.3iuyt.azer
Non-Matches a@a.a | a.@_1.com | azerty_@domain-com

Expression (?<email>(?![ ])(\w|[.])*@(\w|[.])*)
Description E-mail addresses matcher
Matches mpgrewal@rediffmail.com
Non-Matches arnoldschwarz

Expression ^(?:[a-zA-Z0-9_'^&amp;/+-])+(?:\.(?:[a-zA-Z0-9_'^&amp;/+-])+)*@(?:(?:\[?(?:(?: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]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$
Description this will validate most legal email addresses, even allows for some discouraged but perfectly legal characters in local part; allows IP domains with optional []; keeps final tld at a minmum of 2 chars; non capturing groups for efficiency
Matches you.me.hello@somewhere.else.cc | joe_smith@here.com. | me@[24.111.232.1]
Non-Matches .me.you@here.com | .murat@62.59.114.103.nl | test_case@here*555%there.com

Expression ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$
Description Email validation based on Rob Eberhardt's (Thanks, Rob!) email expression, but allows single letter subdomains...
Matches bob@smith.com | bob@j.smith.museum | bob.smith@a-1.smith.com
Non-Matches bob@.com | bob@-a.smith.com

Expression ^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$
Description
Matches mahesh@yahoo.com | mahehs_t@yahoo.com
Non-Matches dot_dot@dot_i.com

Expression ^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$
Description Matches 99.99% of e-mail addresses (excludes IP e-mails, which are rarely used). The {2,7} at the end leaves space for top level domains as short as .ca but leaves room for new ones like .museum, etc. The ?: notation is a perl non-capturing notation, and can be removed safely for non-perl-compatible languages. See also email.
Matches joe.tillis@unit.army.mil | jack_rabbit@slims.com | foo99@foo.co.uk
Non-Matches find_the_mistake.@foo.org | .prefix.@some.net
===========================================================================
Uri
============================================================================
Expression ^[^\\\./:\*\?\"<>\|]{1}[^\\/:\*\?\"<>\|]{0,254}$
Description Validates a long filename using Windows' rules. Requires one valid filename character other than &quot;.&quot; for the first character and then any number of valid filename characters up to a total length of 255 characters. Unresolved is how to prevent the last character from being a &quot;.&quot; while still meeting all the features that this regex does now.
Matches abcd.jpg | a b239.abcd ef12983 298 | a....23498
Non-Matches .abcde.jpg | abcde?.jpg | c:\abcde.jpg

Expression \A([A-Za-z0-9'~`!@#$%&amp;^_+=\(\){},\-\[\]\;])+?([ A-Za-z0-9'~` !@#$%&amp;^_+=\(\){},\-\[\];]|([.]))*?(?(3)(([ A-Za-z0-9'~`!@#$ %&amp;^_+=\(\){},\-\[\]\;]*?)([A-Za-z0-9'~`!@#$%&amp;^_+=\(\){},\-\[ \];])+\z)|(\z))
Description Used to match windows filenames. Fails if there is leading or trailing spaces. Fails if the input contains /\:*?&quot;&lt;&gt;| . Fails if the input begins or ends with '.'
Matches Test.txt | T est.txt | Rosco's.Test.txt
Non-Matches \Folder\Test.txt | T*est.txt | Test.

Expression ^(\$)?(([1-9]\d{0,2}(\,\d{3})*)|([1-9]\d*)|(0))(\.\d{2})?$
Description Modified Joe Lynwood's to allow zero amounts. Handles US Dollars including zero dollars.
Matches $1,234,567.89 | 1234567.89 | $0.00
Non-Matches $1,2345,67.89 | $1234,345,678.0

Expression ([\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(\b|\W(?<!&|=)(?!\.\s|\.{3}).*?))(\s|$)
Description This will find URLs in plain text. With or without protocol. It matches against all toplevel domains to find the URL in the text.
Matches http://www.website.com/index.html | www.website.com | website.com
Non-Matches Works in all my tests. Does not capture protocol.

Expression ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$
Description Checks domain names. This validates domains based on latest specifications (RFCs 952 and 1123 dealing with hostnames and RFC 1035 dealing with domain name system requirements) except that it only includes realistic fully-qualified domains: 1. requires at least one subdomain 2. allows shortest top-level domains like &quot;ca&quot;, and &quot;museum&quot; as longest. Other validation rules: 1. Labels/parts should be seperated by period. 2. Each label/part has maximum of 63 characters. 3. First and last character of label must be alphanumeric, other characters alphanumeric or hyphen. 4. Does not check maxlength of domain which incidentally is 253 characters of text (255 binary representation). For a regular expression that matches ALL domains: ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$
Matches regexlib.com | this.is.a.museum | 3com.com
Non-Matches notadomain-.com | helloworld.c | .oops.org

Expression ^[^\\\/\?\*\&quot;\'\&gt;\&lt;\:\|]*$
Description Validation of a Folder Name. Excludes all forbidden characters
Matches 321321321 dasds
Non-Matches /\3fsdfsd

Expression ^([a-zA-Z]\:) (\\{1}| ((\\{1}) [^\\] ([^/:*?&lt;&gt;&quot;|]*(?&lt;![ ])))+)$
Description Validates windows path and invalidates UNC path
Matches c:\34\445\546\3.htm | C:\
Non-Matches \\qaz | c:\Ram&lt;\ | C: or c:\\ or \\

Expression ^(([a-z][0-9])|([0-9][a-z])|([a-z0-9][a-z0-9\-]{1,2}[a-z0-9])|([a-z0-9][a-z0-9\-](([a-z0-9\-][a-z0-9])|([a-z0-9][a-z0-9\-]))[a-z0-9\-]*[a-z0-9]))\.(co|me|org|ltd|plc|net|sch|ac|mod|nhs|police|gov)\.uk$
Description UK domain names. Includes the following restrictions from Nominet as at time of posting: 1.Only a-z, 0-9 and hyphen may be used. 2.First or last character may not be a hyphen. 3.Third and fourth characters may not both be hyphens. 4.Third level domain may not be a single character. 5.Third level domain may not be two letters or two numbers. 6.Third level domain may be one letter and one number. This does not yet include the following restrictions: 1.Whole domain may not be longer than 64 characters in length. 2.Third level domain may not duplicate any top/second level domain.
Matches zeropanic.co.uk | z2.co.uk | 1-1.org.uk
Non-Matches zeropanic.com | z.co.uk | zz.co.uk

Expression \[link="(?<link>((.|\n)*?))"\](?<text>((.|\n)*?))\[\/link\]
Description This can be used in conjunction with the replace method to provide pseudo-code support without having to enable HTML. The replacement string (in ASP.NET, use RegExp.Replace(SourceString, RegularExpressionPattern, ReplacementString) is &lt;a href=&quot;${link}&quot;&gt;${text}&lt;/a&gt;.
Matches [link="http://www.yahoo.com"]Yahoo[/link]
Non-Matches [link]http://www.yahoo.com[/link] | [link=http://www.yahoo.com]Yahoo[/link]

Expression ^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$
Description Version 1.3.0: I needed a regexp to validate URL's without the ht(f)tp(s):// and include North American domains (like .us and .ca) and there didn't seem to be one available...so I created one. It will also work with ASP QueryStrings and anchor URL's. If you have a problem with the expression or have any suggestions to improve, please write me and let me know. Added .uk domain and expression now allows for URLs that contain JSP session IDs. 4/14/04 - added ability to include URLs that start with server names.
Matches www.blah.com:8103 | www.blah.com/blah.asp?sort=ASC | www.blah.com/blah.htm#blah
Non-Matches www.state.ga | http://www.blah.ru

Expression (((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&amp;%_\./-~-]*)?
Description You can use this regular expression in your PHP scripts to convert entered URL in text to URL link. Example: $text=ereg_replace(&quot;(((file|gopher|news|nntp|telnet|http|ftp|https|ftps|sftp)://)|(www\.))+(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9\&amp;%_\./-~-]*)?&quot;,&quot;&lt;a href=\&quot;./redir.php?url=\\0\&quot; target=\&quot;_blank\&quot;&gt;\\0&lt;/a&gt;&quot;,$text);
Matches http://diskusneforum.sk | www.diskusneforum.sk | ftp://123.123.123.123/
Non-Matches diskusneforum.sk

Expression ^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$
Description Matches full and compressed IPv6 addresses as defined in RFC 2373 (http://www.faqs.org/rfcs/rfc2373.html). No useful captures. Various implementations require different terminators. (i.e. ^-$ or \b-\b)
Matches FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 | 1080::8:800:200C:417A | ::FFFF:129.144.52.38
Non-Matches FEDC::7654:3210::BA98:7654:3210 | FEDC:BA98:7654:3210 | ::

Expression ([A-Z]:\\[^/:\*\?<>\|]+\.\w{2,6})|(\\{2}[^/:\*\?<>\|]+\.\w{2,6})
Description This regular expression pattern can be used to check the validity of paths for file upload controls. The uploaded file can be either stored locally or accessible through UNC. It cannot contain illegal characters for the windows OS - that may be supported e.g. on Mac OS – and cannot be a URL (Yes, as weird as it may seem, some users enter URLs in the file upload box, even though there is a browse button...)
Matches C:\temp\this allows spaces\web.config | \\Andromeda\share\file name.123
Non-Matches tz:\temp\ fi*le?na:m<e>.doc | \\Andromeda\share\filename.a

Expression (\s|\n|^)(\w+://[^\s\n]+)
Description will match free floating valid protocol + urls in text ... will not touch the ones wrapped in a tag, so that you can auto-link the ones that aren't :) couple of things to know : 1. if the url is next to a tag this won't work (eg : &lt;br&gt;http://www.acme.com), the url must either start with a \s, \n or any character other than &gt;. 2. the pattern will match the preceding \s and \n too, so when you replace put them back in place $1 will either be \s or \n, $2 will be the exact match vb usage : set re = New RegExp re.Pattern =&quot;(\s|\n|^)(\w+://[^\s\n]+)&quot; strResult = re.Replace(strText, &quot;$1&lt;a href='$2' target='_new'&gt;$2&lt;/a&gt;&quot;)
Matches http://www.acme.com | ftp://ftp.acme.com/hede | gopher://asdfasd.asdfasdf
Non-Matches &lt;a href=&quot;http://acme.com&quot;&gt;http://www.acme.com&lt;/a&gt; | &lt;br&gt;http://www.acme.

Expression (?!\.)[a-z]{1,4}$
Description Matches files extension
Matches file.jpg | file.c | file.gif
Non-Matches file.34

Expression [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
Description Very Simple Match for dotted Decimal IP address. Doesn’t Validate addresses
Matches 192.168.1.1 | 10.2.234.1 | 66.129.71.122
Non-Matches 192.168.1 | 10.2.1234.1 | 66 129 71 122

Expression (?:(?<protocol>http(?:s?)|ftp)(?:\:\/\/)) (?:(?<usrpwd>\w+\:\w+)(?:\@))? (?<domain>[^/\r\n\:]+)? (?<port>\:\d+)? (?<path>(?:\/.*)*\/)? (?<filename>.*?\.(?<ext>\w{2,4}))? (?<qrystr>\??(?:\w+\=[^\#]+)(?:\&?\w+\=\w+)*)* (?<bkmrk>\#.*)?
Description I needed a regular expression to break urls into labled parts. This is what I came up with. Got a few ideas from regexlib.com and from this msdn article. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/reconbackreferences.asp http://www.domain.com/folder does return a match but will not grab the folder name unless there is &quot;/&quot; at the end. http://www.domain.com/folder/
Matches https://192.168.0.2:80/users/~fname.lname/file.ext | ftp://user1:pwd@www.domain.com | http://www.dom
Non-Matches www.domain.com | user1:pwd@domain.com | 192.168.0.2/folder/file.ext

Expression ((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)
Description Regular Expression matches any internet URLs. Used with the replace method it comes in very handy.
Matches http://www.aspemporium.com | mailto:dominionx@hotmail.com | ftp://ftp.test.com
Non-Matches www.aspemporium.com | dominionx@hotmail.com | bloggs

Expression (a(?:[cdefgilmnoqrstuwxz]|ero|(?:rp|si)a)|b(?:[abdefghijmnorstvwyz]iz)|c(?:[acdfghiklmnoruvxyz]|at|o(?:m|op))|d[ejkmoz]|e(?:[ceghrstu]|du)|f[ijkmor]|g(?:[abdefghilmnpqrstuwy]|ov)|h[kmnrtu]|i(?:[delmnoqrst]|n(?:fo|t))|j(?:[emop]|obs)|k[eghimnprwyz]|l[abcikrstuvy]|m(?:[acdeghklmnopqrstuvwxyz]|il|obi|useum)|n(?:[acefgilopruz]|ame|et)|o(?:m|rg)|p(?:[aefghklmnrstwy]|ro)|qa|r[eosuw]|s[abcdeghijklmnortuvyz]|t(?:[cdfghjklmnoprtvwz]|(?:rav)?el)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])
Description This regexp matches all existing TLDs (Top-Level Domains) according to IANA specifications as of 14/07/2007.
Matches all ccTLDs (Country-Code Top-Level Domains) | all gTLDs (Generic Top-Level Domains) | .arpa
Non-Matches n.o.n - e.x.i.s.t.i.n.g T.L.D.s


Expression \b([\d\w\.\/\+\-\?\:]*)((ht|f)tp(s|)\:\/\/|[\d\d\d|\d\d]\.[\d\d\d|\d\d]\.|www\.|\.tv|\.ac|\.com|\.edu|\.gov|\.int|\.mil|\.net|\.org|\.biz|\.info|\.name|\.pro|\.museum|\.co)([\d\w\.\/\%\+\-\=\&amp;\?\:\\\&quot;\'\,\|\~\;]*)\b
Description Url matching
Matches http://210.50.2.215/sd_new/WebBuilder.cgi?RegID=7449046&amp;First=Ok&amp;Upt=Ok&amp;EditPage=3&amp;S
Non-Matches Hmmmm

=======================================================================

Numbers

======================================================================
Expression ^\d{1,7}$
Description Positive Whole number matched from 0 to 9999999. Only 7 digits length is allowed.
Matches 1234567 | 9999999 | 1
Non-Matches 12345678 | 9999.99 | -1234

Expression ^\d+(?:\.\d{0,2})?$
Description Matches positive whole numbers with exactly zero or two decimal points if a . is present. Useful for checking currency amounts, such 5 or 5.00 or 5.25.
Matches 1 | 1.23 | 1234.45
Non-Matches a1.34 | 1.23a | a

Expression ^\d*$
Description Accepts an unsigned integer number. Also matches empty strings.
Matches 123 | 000 | 43
Non-Matches asbc | -34 | 3.1415

Expression ^[-+]?\d*\.?\d*$
Description Matches any floating point numer/numeric string, including optional sign character (+ or -). Also matches empty strings.
Matches 123 | +3.14159 | -3.14159
Non-Matches abc | 3.4.5 | $99.95

Expression ^((\d?)|(([-+]?\d+\.?\d*)|([-+]?\d*\.?\d+))|(([-+]?\d+\.?\d*\,\ ?)*([-+]?\d+\.?\d*))|(([-+]?\d*\.?\d+\,\ ?)*([-+]?\d*\.?\d+))|(([-+]?\d+\.?\d*\,\ ?)*([-+]?\d*\.?\d+))|(([-+]?\d*\.?\d+\,\ ?)*([-+]?\d+\.?\d*)))$
Description This allows a sequence of real numbers to be added, separated by a comma (required) and a space (optional). Based pretty heavily on an expression by Steven Smith on this site.
Matches 8.0 | 8.0,-.38,+8.9 | 8.0, +8.8, 0.09
Non-Matches + | . | a,b, c

Expression ^[+]?\d*$
Description This re was used for set numbers only! Somente numeros s&#227;o requeridos!
Matches 0123456789 | 1234 | 1
Non-Matches 1.0?&amp; | a1 | 2a-

Expression ^(\d|,)*\.?\d*$
Description Matches Numeric with Commas and a single decimal point. Also matches empty string.
Matches 1,000 | 3,000.05 | 5,000,000
Non-Matches abc | $100,000 | Forty

Expression ^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$
Description This re matches US currency format with lead dollar sign. Dollar value must have at least one digit and may or may not be comma separated. Cents value is optional.
Matches $0.84 | $123458 | $1,234,567.89
Non-Matches $12,3456.01 | 12345 | $1.234

Expression ^[-+]?\d+(\.\d+)?$
Description This matches any real number, with optional decimal point and numbers after the decimal, and optional positive (+) or negative (-) designation.
Matches 123 | -123.45 | +123.56
Non-Matches 123x | .123 | -123.

Expression ^\d*\.?((25)|(50)|(5)|(75)|(0)|(00))?$
Description This is a pattern to search and verify that a decimal number ends with a 25, 50, 75, 0 or 00. It does match for a nothing after decimal also but I guess thats ok !!
Matches 0.25 | .75 | 123.50
Non-Matches .77 | 1.435

Expression ^[-+]?[0-9]\d{0,2}(\.\d{1,2})?%?$
Description Required and regular expression validator. For supporting -999.99 to +999.99 . Positive and Negative integer/ decimal validations. Percentage sign is also supported. Will not allow empty strings. Can increase/decrease the range as you need.
Matches 12.3 | 123 | -123.45
Non-Matches - | 10.1234 | -1234

Expression ^[-+]?\d*$
Description Matches any integer number or numeric string, including positive and negative value characters (+ or -). Also matches empty strings.
Matches 123 | -123 | +123
Non-Matches abc | 3.14159 | -3.14159

Expression ^(?=.*[1-9].*$)\d{0,7}(?:\.\d{0,9})?$
Description Allows up to seven digits to the left and up to nine digits to the right of an optional decimal place. Leading zeros on the left of the decimal are accepted. Only positive values are accepted.
Matches 1 | 0123456.123456789 | .123456789
Non-Matches .0123456789 | 0.0 | -1

Expression ^(\d{1,3}'(\d{3}')*\d{3}(\.\d{1,3})?|\d{1,3}(\.\d{3})?)$
Description This regex match numeric data in the following format: thousands are separated by (') apostrophe, decimal places are separated by dot (.) Maximum three decimal places are not required. It's easy to change to other separators as well.
Matches 1'235.140 | 1'222'333.120 | 456
Non-Matches 1234.500 | 78'45.123 | 123,0012


Expression ^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$
Description This matches floating point expression in a more rigorous way - accepts both exponent as well as non exponent notations.
Matches 123 | -123.35 | -123.35e-2
Non-Matches abc | 123.32e | 123.32.3

Expression ^\$?\d+(\.(\d{2}))?$
Description To evaluate an amount with or without a dollar sign where the cents are optional.
Matches $2.43 | 2.02 | $2112
Non-Matches 2.1 | $.14 | $2,222.12

Expression ^(?!\u00a2) #Don't allow cent symbol \p{Sc}? #optional unicode currency symbols (?!0,?\d) #don't allow leading zero if 1 or more unit (\d{1,3} # 1 to 3 digits (\,\d{3})* # if the is a comma it must be followed by 3 digits |(\d+)) # more than 3 digit with no comma separator (\.\d{2})?$ # option cents
Description This regex validates Currency. The base monetary unit (ex. US dollar) followed by option two digit cent denomination. Base unit can't have leading zero. Comma's are optional on base units. Note: Your regex engine must support the \p character class to use this. For example this will work in .net but not javascript which doesn't support \p Also the &#162; is removed from the match by force. Any other cent symbol would need to be added to the exclude to not match.
Matches $1,501.13 | &#163;215 | €4.93
Non-Matches 01.00 | $.00 | &#162;50

Expression ^-?[0-9]{0,2}(\.[0-9]{1,2})?$|^-?(100)(\.[0]{1,2})?$
Description Matches a negative or positive percentage between 0 and 100 (inclusive). Accepts up to 2 decimal places.
Matches 12.34 | 100.00 | -2.1
Non-Matches 101.1 | 10.123 | 100.10

Expression ^([1-9]{0,1})([0-9]{1})(\.[0-9])?$
Description Matches numbers 0 through 99.9 Allows only one preceding zero and does not require the decimal point
Matches 1 | 1.1 | 0.1
Non-Matches 01 | 01.1 | 0.10

Expression ^\$?\-?([1-9]{1}[0-9]{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\-?\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))$|^\(\$?([1-9]{1}\d{0,2}(\,\d{3})*(\.\d{0,2})?|[1-9]{1}\d{0,}(\.\d{0,2})?|0(\.\d{0,2})?|(\.\d{1,2}))\)$
Description currency format that allows optional $, optional &quot;-&quot;(MinusSignNegative) OR &quot;()&quot; (ParenNegative) but not both, optional cents, and optional commas separating thousands. Minus sign can be before or after $, but parens must be outside the $. UPDATED: now fails to match a &quot;$&quot; without any further numbers
Matches ($4,000.00) | -$4000.00 | -$400.00
Non-Matches 4,00.000 | abc | $
==========================================================================
String
==========================================================================
Expression ^[a-zA-Z0-9]+$
Description it will check for alphanumeric (Alpha Numeric) values.
Matches adad1213 | 1231dfadfa | dfad123dfasdfs
Non-Matches dfa@#12313 | *(*sdfasdfadfd | $fffsdg121ddd#$f1q

Expression ^[{|\(]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[\)|}]?$
Description Specifier Format of Guid Values that this RegEx supports: 32 digits: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 32 digits separated by hyphens: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx] 32 digits separated by hyphens, enclosed in brackets: [{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}] 32 digits separated by hyphens, enclosed in parentheses: [(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
Matches 914D226A-2F5B-4944-934D-96BBE6571977 | {914D226A-2F5B-4944-934D-96BBE6571977}
Non-Matches 914D226A-2F5B-4944-XXXX-96BBE6571977 | {914D226A-2F5B-4944-XXXX-96BBE6571

Expression ^[\.\w&#230;&#248;&#229;-]+@([a-z&#230;&#248;&#229;0-9]+([\.-]{0,1}[a-z&#230;&#248;&#229;0-9]+|[a-z&#230;&#248;&#229;0-9]?))+\.[a-z]{2,6}$
Description Well it pretty much accepts all kinds of users, about the domain i didn't write it special for any TLD so there's no length defined, ohh and it accepts some IDN stuff
Matches afdaas-ddas----asddas____...@asd.asd.asd.asd.asd.com | a@a.aa | .@microsoft.sun.apple.com
Non-Matches aaaaaaa@.-com | aaaaaaa@adf.-com | aaaaaaa@

Expression .*[Oo0][Ee][Mm].*
Description Spam Stopper
Matches OEM | 0em
Non-Matches na

Expression ^([\s\S]){1,20}([\s\.])
Description This pattern returns as much of the first x characters of a string as full words or sentences as a match, where x is currently 20. Change x to adjust the length supported in your database field. I'm currently using this within a string shortening utility to shrink large text regions to word/sentance-boundary elements and appending an ellipsis as a text continuator.
Matches Any text of any length | ...but will only 'match' the first 20 characters at a period or space.
Non-Matches N/A

Expression (?s)(?:\e\[(?:(\d+);?)*([A-Za-z])(.*?))(?=\e\[|\z)
Description This expression will match all of the commands(escape codes) used in ANSI files. These are what were used to create the colors/blocks on BBS's for those of us that once dialed into them. http://www.wikipedia.org/wiki/ANSI_escape_code has a reference for ANSI escape codes. http://idledreams.net/lordscarlet/posts/153.aspx shows an example of the engine I have created surrounding the expression
Matches [32mHello | [1;35mTest | [2J
Non-Matches abc

Expression (NOT)?(\s*\(*)\s*(\w+)\s*(=|&lt;&gt;|&lt;|&gt;|LIKE|IN)\s*(\(([^\)]*)\)|'([^']*)'|(-?\d*\.?\d+))(\s*\)*\s*)(AND|OR)?
Description Heres my sql clause parser regexp for recordset filtering. Does recursive query parsing all by its self. Only problem I cant figure is how to match comma separated lists of quoted strings. Tell me if you figure out how! The unicodes in the re was put in by the entry form please replace them with their ascii equivalents to use it.
Matches Aeroplane LIKE 767 | Movie LIKE 'Star' AND NOT Movie LIKE 'Trek' | Number IN (1,2,3,4,5)
Non-Matches Hello there | A=EXCELLENT OR | B!=POOR

Expression ^((Bob)|(John)|(Mary)).*$(?<!White)
Description &quot;Starts with but does not end with.&quot; I needed a pattern to require certain first (and optional middle) names, but to fail for certain last names. So if Bob, John, and Mary are acceptable first names but the White's are always rejected then...
Matches Bob Jones | John Smith | Mary Jane Smith
Non-Matches Bob White | Mary Doe White | Gina Smith

Expression (\d{6}[-\s]?\d{12})|(\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4})
Description Credit card validator Works for switch card numbers too Switch card bit is (\d{6}[-\s]?\d{12}) Credit card bit is (\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}) I use this as a client side test before running a more comprehensive server side check.
Matches 5111 1111 1111 11118 | 1234123412341324 | 123456 123456789012
Non-Matches 511a 1111 1111 11118

Expression ^([A-Z]{3}\s?(\d{3}|\d{2}|d{1})\s?[A-Z])|([A-Z]\s?(\d{3}|\d{2}|\d{1})\s?[A-Z]{3})$
Description UK vehicle registration system prior to September 2001. Allows both older suffix and the later prefix formats in simple form, with optional spaces.
Matches ABC123A | A 123 ABC
Non-Matches AB123A | A 123 AB

Expression (\S+)\x20{2,}(?=\S+)
Description Trim Inside. This pattern can be used with a replace value of &quot;$1 &quot; to remove multiple consecutive spaces between characters and replace with a single space. Trailing and leading spaces are NOT altered.
Matches Too Many spaces.
Non-Matches No extra spaces | No Extra spaces Inside

Expression ^([A-Z]{3}\s?(\d{3}|\d{2}|d{1})\s?[A-Z])|([A-Z]\s?(\d{3}|\d{2}|\d{1})\s?[A-Z]{3})|(([A-HK-PRSVWY][A-HJ-PR-Y])\s?([0][2-9]|[1-9][0-9])\s?[A-HJ-PR-Z]{3})$
Description UK vehicle registration system. This is the obvious combination of two previous expressions posted here, to merge the older system with the current system.
Matches ABC 123 A | A 123 ABC | AB 12 ABC
Non-Matches AB 123 C | A 123 AB | AB 12 AB

Expression ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$
Description Password matching expression. Password must be at least 8 characters, no more than 15 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit.
Matches aaaa1234AAAA | 12aaAA12 | aaaaa12345AAAAA
Non-Matches aaaaa123456AAAAA | 12aaAA1 | 12aaaa12

Expression ^(?<field1>[^,]+),(?<field2>[^,]+),(?<field3>[^,]+)$
Description Example of a regular expression that can be used to parse a comma delimited string into constituent, named sub-strings. Add or remove regex subfield definitions (?&lt;field1&gt;[^,]+) and corresponding delimiting characters in the regular expression as necessary to accommodate the string and subfields you intend to parse. Optionally, rename the subfield names in the regular expression to more meaningful names if you are using the parsed sub-strings in a program. Replace all occurrences of the comma in the regular expression with any required alternative delimiting character. As long as the delimiting character used does not occur naturally in any of the sub-strings, you should be good-to-go. NOTE: To change the delimiter character you must replace all occurrences of the comma in the current regex (of which there are 5) with the new delimiter character. e.g. (?&lt;field1&gt;[^;]+); changes the delimiter character to a semi-colon for the first field.
Matches Fred,Barnie,Wilma | Bob,1/1/2003,222-3333 | 100,200,300
Non-Matches Fred,Barnie,Wilma,Betty | Bob;1/1/2003;222-3333 | Tom Dick Harry

Expression ^[A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}[0-9]{6}[A-DFM]{0,1}$
Description UK National Insurance Number (NINo) validation. The following modifications have been made: The first letter may not be D, F, I, Q, U or Z; the second letter may not be D, F, I, O, Q, U or Z; the final letter is optional.
Matches JG103759A | AP019283D | ZX047829C
Non-Matches DC135798A | FQ987654C | KL192845T

Expression (?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$
Description I built this expression to test a string in ASP for valid username and password constraints. It can be adapted for any number of scenerios. For instance in this case, we needed to ensure the username someone wanted was not all numbers or all letters and was 6-15 characters in length with no special characters. This expression tests negatively for all number cases, then all letter cases, and lastly tests for only alphanumeric characters in the required range. In other words: the match must be alphanumeric with at least one number, one letter, and be between 6-15 character in length.
Matches C2dfeed | sporttrak1 | 11223a
Non-Matches pookie | d34_fff | 123456


Expression ^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$
Description This regex validates U.S. social security numbers, within the range of numbers that have been currently allocated.
Matches 078-05-1120 | 078 05 1120 | 078051120
Non-Matches 987-65-4320 | 000-00-0000 | (555) 555-5555

Expression ^(\d{4}-){3}\d{4}$|^(\d{4} ){3}\d{4}$|^\d{16}$
Description Used to validate Credit Card numbers, Checks if it contains 16 numbers in groups of 4 separated by -, ,or nothing
Matches 1111-2323-2312-3434 | 1234343425262837 | 1111 2323 2312 3434
Non-Matches 1111 2323 2312-3434 | 34323423 | 1111-2323-23122-3434

Expression ^([A-Z|a-z|&amp;]{3}\d{2}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|([02468][048]|[13579][26])0229)(\w{2})([A|a|0-9]{1})$|^([A-Z|a-z]{4}\d{2}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|([02468][048]|[13579][26])0229)((\w{2})([A|a|0-9]{1})){0,3}$
Description Registro Federal de Contribuyentes (RFC) , used in Mexico as a unique set of caracters for a person or corporation registration . Registro Federal de Contribuyentes utilizado en Mexico para el registro en hacienda.
Matches ABCD790419 | ABC790419aa1 | ABCD790419AB1
Non-Matches AB790419 | A12790419 | ABC791332

Expression (\w(\s)?)+
Description Used to verify that the string consists of only A-z, 0 - 9 and underscore. Several words allowed, only one space between them. No spaces up front. Hey, I know it's easy, but it was not in the library! Plus, the test option here is not working well all the time.
Matches Test | TesT | tesT9 _test9
Non-Matches \\\
====================================================================================
Date-Time
===================================================================================
Expression (?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$
Description mm/dd/yyyy hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=644. Please see that regex for details of what is being checked
Matches 11/24/0004 11:59 PM | 2.29.2008 | 02:50:10
Non-Matches 12/33/1020 | 2/29/2005 | 13:00 AM


Expression ^(?=\d)(?:(?!(?:(?:0?[5-9]|1[0-4])(?:\.|-|\/)10(?:\.|-|\/)(?:1582))|(?:(?:0?[3-9]|1[0-3])(?:\.|-|\/)0?9(?:\.|-|\/)(?:1752)))(31(?!(?:\.|-|\/)(?:0?[2469]|11))|30(?!(?:\.|-|\/)0?2)|(?:29(?:(?!(?:\.|-|\/)0?2(?:\.|-|\/))|(?=\D0?2\D(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|2[0-8]|1\d|0?[1-9])([-.\/])(1[012]|(?:0?[1-9]))\2((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?:$|(?=\x20\d)\x20)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$
Description dd/mm/yyyy hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=691. Please see that regex for details of what is being checked
Matches 31.12.6008 | 5:30 AM | 30-04-1066
Non-Matches 00/00/0000 | 99:99:99 | 29/02/2005

Expression (?#Calandar from January 1st 1 A.D to December 31, 9999 )(?# in yyyy-mm-dd format )(?!(?:1582\D10\D(?:0?[5-9]|1[0-4]))|(?#Missing days from 1582 )(?:1752\D0?9\D(?:0?[3-9]|1[0-3]))(?#or Missing days from 1752 )(?# both sets of missing days should not be in the same calendar so remove one or the other))(?n:^(?=\d)(?# the character at the beginning a the string must be a digit )((?'year'\d{4})(?'sep'[-./])(?'month'0?[1-9]|1[012])\k'sep'(?'day'(?<!(?:0?[469]|11).)31|(?<!0?2.)30|2[0-8]|1\d|0?[1-9]|(?# if feb 29th check for valid leap year )(?:(?<=(?!(?#exclude these years from leap year pattern ) 000[04](?#No year 0 and no leap year in year 4 )|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00)(?# centurial years > 1500 not evenly divisible by 400 are not leap year))(?:(?:\d\d)(?# century)(?:[02468][048]|[13579][26])(?#leap years))\k'sep'(?:0?2)\k'sep')|(?# else if not Feb 29 )(?<!\k'sep'(?:0?2)\k'sep')(?# and day not Feb 30 or 31 ))29)(?(?=\x20\d)\x20|$))?(?# if there is a space followed by a digit check for time )(?<time>((?# 12 hour format )(0?[1-9]|1[012])(?# hours )(:[0-5]\d){0,2}(?# optional minutes and seconds )(?i:\x20[AP]M)(?# required AM or PM ))|(?# 24 hour format )([01]\d|2[0-3])(?#hours )(:[0-5]\d){1,2})(?#required minutes optional seconds )?$)
Description yyyy-mm-dd Datetime for AD, with leap year. See http://blogs.regexadvice.com/mash/archive/2004/04/23/1021.aspx for details on similar regexs
Matches 0001-06-16 12:00:01 AM | 2004/2/29 | 3:30 PM
Non-Matches 9999/99/99 | 24:00:00 | 2003-02-29

Expression ^((((31\/(0?[13578]|1[02]))|((29|30)\/(0?[1,3-9]|1[0-2])))\/(1[6-9]|[2-9]\d)?\d{2})|(29\/0?2\/(((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|(0?[1-9]|1\d|2[0-8])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d)?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$
Description this expression validates a date-time field in European d/m/y h:m:s format. It is a european variation of Michael Ash's date-validation expression in this library. The days are validated for the given month and year. Leap years are validated for all 4 digits years from 1600-9999, and all 2 digits years except 00
Matches 29/02/2004 20:15:27 | 29/2/04 8:9:5 | 31/3/2004 9:20:17
Non-Matches 29/02/2003 20:15:15 | 2/29/04 20:15:15 | 31/3/4 9:20:17

Expression ^((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))$
Description Matches times seperated by either : or . will match a 24 hour time, or a 12 hour time with AM or PM specified. Allows 0-59 minutes, and 0-59 seconds. Seconds are not required.
Matches 1:01 AM | 23:52:01 | 03.24.36 AM
Non-Matches 19:31 AM | 9:9 PM | 25:60:61

Expression ^(?=\d)(?:(?!(?:1582(?:\.|-|\/)10(?:\.|-|\/)(?:0?[5-9]|1[0-4]))|(?:1752(?:\.|-|\/)0?9(?:\.|-|\/)(?:0?[3-9]|1[0-3])))(?=(?:(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:\d\d)(?:[02468][048]|[13579][26]))\D0?2\D29)|(?:\d{4}\D(?!(?:0?[2469]|11)\D31)(?!0?2(?:\.|-|\/)(?:29|30))))(\d{4})([-\/.])(0?\d|1[012])\2((?!00)[012]?\d|3[01])(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$
Description yyyy/mm/dd hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=760. Please see that regex for details of what is being checked
Matches 0008-02-29 | 2:34:59 PM | 9999/12/31 11:59 PM
Non-Matches 04/04/04 | 1:00 | 1999/1/32

Expression ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/(\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/(\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/(\d{2}))|(29\/02\/((0[48]|[2468][048]|[13579][26])|(00))))$
Description Matching : dd/MM/yy Leap years compatible Italian style, just for more fun. Please, don't forget to rate it if you use it. THX
Matches 31/12/75 | 29/02/00 | 29/02/04
Non-Matches 01/13/01 | 29/02/01 | 29/02/2004

Expression ((0[1-9])|(1[02]))/\d{2}
Description Fromat check for MM/YY, checks month is 1-12 and any 2 digit year.
Matches 01/00 | 12/99
Non-Matches 13/00 | 12/AS

Expression (^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)|(^([0-9]|[1][0-9]|[2][0-3])$)
Description Matches a string if it is a valid time in the format of HH:MM / H:MM / HH / H
Matches 10:35 | 9:20 | 23
Non-Matches 24:00 | 20 PM | 20:15 PM

Expression ^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$
Description This expression validates dates in the y/m/d format from 1600/1/1 - 9999/12/31. Follows the same validation rules for dates as my other date validator (m/d/y format) located in this library.
Matches 04/2/29 | 2002-4-30 | 02.10.31
Non-Matches 2003/2/29 | 02.4.31 | 00/00/00

Expression ^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$
Description DD.MM.YY or DD.MM.YYYY separator could be on choice '.' '/' or '-' leap years compatible, 00 is treated as year 2000.
Matches 29.2.04 | 29/02-2004 | 3.4.05
Non-Matches 29.2.03 | 2902.2004 | 12.31.1975

Expression ^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
Description DateTime Validator. This RE validates both dates and/or times patterns. Days in Feb. are also validated for Leap years. Dates: in dd/mm/yyyy or d/m/yy format between 1/1/1600 - 31/12/9999. Leading zeroes are optional. Date separators can be either matching dashes(-), slashes(/) or periods(.) Times: in the hh:MM:ss AM/PM 12 hour format (12:00 AM - 11:59:59 PM) or hh:MM:ss military time format (00:00:00 - 23:59:59). The 12 hour time format: 1) may have a leading zero for the hour. 2) Minutes and seconds are optional for the 12 hour format 3) AM or PM is required and case sensitive. Military time 1) must have a leading zero for all hours less than 10. 2) Minutes are manditory. 3) seconds are optional. Datetimes: combination of the above formats. A date first then a time separated by a space. ex) dd/mm/yyyy hh:MM:ss This RE is an variation of one of my other Datetime (mm/dd/yyyy) validator already in this library http://www.regexlib.com/REDetails.aspx?regexp_id=369, so the same rules for leap year apply. All 4 digit year and all two digit years except 00, which might not be a leap year.
Matches 31/12/2003 11:59:59 PM | 29-2-2004 | 01:45:02
Non-Matches 12/31/2003 | 29.02.2005 | 13:30 PM

Expression ^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$
Description This regexp has been posted specialy for &quot;Mike O Shea&quot; as he requested a mono digit year validation. matches DD/MM/Y or DD/MM/YYYY or D/M/Y or DD/M/YYYY Leap years treated. (Italian style with tomato) Years 0-9 equal years 2000 to 2009 for leap years
Matches 1/1/2005 | 29/02/12 | 29/02/2400
Non-Matches 29/2/2005 | 29/02/13 | 29/02/2200

Expression ^(([0]?[0-5][0-9]|[0-9]):([0-5][0-9]))$
Description This regex is to validate the time of a ~60 minute CD where the most time on the CD is 59:59 (minutes:seconds). It is derived from Ken Madden's time regex for a project for Erik Porter (Windows/Web guru). Written by Jason Gaylord.
Matches 30:05 | 5:05 | 02:59
Non-Matches 25:7 | 5m:16 | 60:60

Expression ^(?ni:(?=\d)((?'year'((1[6-9])|([2-9]\d))\d\d)(?'sep'[/.-])(?'month'0?[1-9]|1[012])\2(?'day'((?<!(\2((0?[2469])|11)\2))31)|(?<!\2(0?2)\2)(29|30)|((?<=((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00)\2\3\2)29)|((0?[1-9])|(1\d)|(2[0-8])))(?:(?=\x20\d)\x20|$))?((?<time>((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2}))?)$
Description YYYY/MM/DD hh:mm:ss format DateTime Regex. This regex will validate a date, time or a datetime. It will also capture the date fields and the time. Dates are in the YYYY/MM/DD format and validated for months, number of days in a month and leap years (29/2) Date field can be separated by matched periods(.), dashes(-) or forward slashes(/) Time is either 12 hour AM/PM format (hh:mm:ss AM), where minutes and seconds are optional. AM or PM required. or 24 hour military format (hh:mm:ss), from 00:00:00 to 23:59:59, where hours and minutes fields are required, including leading 0 for hours less than 10. Please refer to http://blogs.regexadvice.com/mash/archive/2004/04/23/1021.aspx for additional info Datetime is the above date and time formats separated by a space, with the date first (YYYY/MM/DD hh:mm:ss) !IMPORTANT NOTE: your regex engine must support lookbehinds and named groups to use this expression
Matches 12:30 PM | 2004-02-29 | 2004/3/31 02:31:35 AM
Non-Matches 2:00 | 2200.2.29 | 0000/00/00 00:00:00 AM

Expression ^(((((0[13578])|([13578])|(1[02]))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s(((0[1-9])|([1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$
Description Following expression can be used to validate a datetime column from SQL Server. This expression is an enhanced version of Scott Watermasysk's date/time submission. It now accepts leading zeros in months, days, and hours. In addition, this expression properly handles the 11th hour. Watermasysk's would take the 10th and 12th hour but not the 11th. This regex has been tweaked to do so. Does not handle the February 29th problem on non-leap years yet. Will learn a little more about RegEx and do so in later submission.
Matches 11/30/2003 10:12:24 am | 2/29/2003 08:14:56 pm | 5/22/2003
Non-Matches 11/31/2003 10:12:24 am | 2/30/2003 08:14:56 pm | 5/22/2003 14:15

Expression ^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$
Description This RE validates times patterns.
Matches 1 AM | 23:00:00 | 5:29:59 PM
Non-Matches 13 PM | 13:60:00 | 00:00:00 AM

Expression ^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$
Description Date with leap years. Accepts '.' '-' and '/' as separators d.m.yy to dd.mm.yyyy (or d.mm.yy, etc) Ex: dd-mm-yyyy d.mm/yy dd/m.yyyy etc etc Accept 00 years also.
Matches 29.2.2004 | 31121975 | 29/2-00
Non-Matches 29.2.2005 | 32121975 | 29.2/01

Expression ^((31(?! (FEB|APR|JUN|SEP|NOV)))|((30|29)(?! FEB))|(29(?= FEB (((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8]) (JAN|FEB|MAR|MAY|APR|JUL|JUN|AUG|OCT|SEP|NOV|DEC) ((1[6-9]|[2-9]\d)\d{2})$
Description Validates date format by DD MMM YYYY. Validates days for each month also. Ensures that month is uppercase.
Matches 09 MAY 1981 | 28 JAN 2004 | 8 JUL 2006
Non-Matches 29 FEB 2003 | 28 Oct 2000 | 9 APR 03

Expression ^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$
Description Simple American date format mm-dd-yyyy or mm-dd-yy, no time. Date range is 1900 --&gt; 2099. Is enough for my purposes. Incorectly validates 02-29-1900. I created this to validate dates on a web form where the likely range will be 2000--&gt;2020. Seperators can be '.','/' or '-' Anyone know the rules for operator precedence for regex syntax?
Matches 02-29-2004 | 1/31/1997 | 1-2-03
Non-Matches 02-29-2003 | 04-31-2003 | 31-
====================================================================================
Misc
====================================================================================
Expression ^(V-|I-)?[0-9]{4}$
Description Postcode check for Italy (including possible Vatican/Italy indications)
Matches 1234 | V-1234
Non-Matches 12345

Expression ^[1-9]{1}[0-9]{3} ?[A-Z]{2}$
Description Postcode check for Netherlands
Matches 1234 AB | 1234AB
Non-Matches 123AB | 1234AAA

Expression ^[0-9]{2}[-][0-9]{2}[-][0-9]{2}$
Description Validates a UK Bank Sort code
Matches 09-01-29 | 05-06-25
Non-Matches 090125

Expression ^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$
Description This RE validates alpha characters that evaluate to Roman numerials, ranging from 1(I) - 3999(MMMCMXCIX). Not case sensitive.
Matches III | xiv | MCMXCIX
Non-Matches iiV | MCCM | XXXX


Expression \u00AE
Description Matches the registered trademark (&#174;). Pretty simple, yet I dont think existed on RegExLib before.
Matches ®
Non-Matches anything else

Expression ^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$
Description Postcode check for Spain
Matches 12345 | 10234 | 01234
Non-Matches 00123

Expression ^[^']*$
Description This one matches all strings that do not contain the single quotation mark (').
Matches asljas | %/&amp;89uhuhadjkh | &quot;hi there!&quot;
Non-Matches 'hi there!' | It's 9 o'clock | '''''

Expression ^\d{5}(-\d{4})?$
Description Matches standard 5 digit US Zip Codes, or the US ZIP + 4 Standard.
Matches 48222 | 48222-1746
Non-Matches 4632 | Blake | 37333-32

Expression \p{IsBasicLatin}
Description Matches any character is the Basic Latin Unicode Range \U0000-U007F (Ascii 0-127) I've blogged about this and other expressions here http://blogs.regexadvice.com/mash/archive/2004/04/17/988.aspx
Matches ABCxyz | 123 | +-=
Non-Matches ? | ? | ?

Expression ^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$
Description Validates swedish zipcodes (postnr) with or without space between groups. With leading s- or not. Can be disconnected by removing ''(s-|S-){0,1}''.
Matches 12345 | 932 68 | S-621 46
Non-Matches 5367 | 425611 | 31 545

Expression \d{2}.?\d{3}.?\d{3}/?\d{4}-?\d{2}
Description This regular expressions matches CNPJ number. CNPJ is a Registration Number of Brazilian Companies.
Matches 00.000.000/0000-00 | 00000000000000
Non-Matches 00-000-000-000-00 | AA.AAA.AAA/AAAA-AA

Expression ^[1-9]{1}[0-9]{3}$
Description Postcode for Belgium
Matches 1234
Non-Matches 123 | 123A

Expression &lt;[^&gt;\s]*\bauthor\b[^&gt;]*&gt;
Description This expression will match the corresponding XML/HTML elements opening and closing tags. Useful to handle documents fragments, without loading an XML DOM.
Matches &lt;author name=&quot;Daniel&quot;&gt; | &lt;/sch:author&gt; | &lt;pp:author name=&quot;Daniel&quot;
Non-Matches &lt;other&gt; | &lt;/authors&gt; | &lt;work&gt;author&lt;/work&gt;

Expression (at\s)(?&lt;fullClassName&gt;.+)(\.)(?&lt;methodName&gt;[^\.]*)(\()(?&lt;parameters&gt;[^\)]*)(\))((\sin\s)(?&lt;fileName&gt;.+)(:line )(?&lt;lineNumber&gt;[\d]*))?
Description Just a simple regExp to parse the stack trace. Developed when using the exception block from MS, coz they only showed the stack all bunched together. Could be used as follows: [C#] string regExParams = @&quot;(at\s)(?&lt;fullClassName&gt;.+)(\.)(?&lt;methodName&gt;[^\.]*)(\()(?&lt;parameters&gt;[^\)]*)(\))((\sin\s)(?&lt;fileName&gt;.+)(:line )(?&lt;lineNumber&gt;[\d]*))?&quot;; Regex re = new System.Text.RegularExpressions.Regex(regExParams,RegexOptions.Compiled); MatchCollection mtc; mtc = re.Matches(System.Environment.StackTrace); foreach(Match mt in mtc) { MessageBox.Show(mt.Result(&quot;${fullClassName}&quot;)); MessageBox.Show(mt.Result(&quot;${methodName}&quot;)); MessageBox.Show(mt.Result(&quot;${parameters}&quot;)); MessageBox.Show(mt.Result(&quot;${fileName}&quot;)); MessageBox.Show(mt.Result(&quot;${lineNumber}&quot;)); } Seems to work well, but use at your own peril!! Feel free to use and enhance (there's probably a lot that could be done, like getting parameters individually(?), etc)
Matches at System.IO.__Error.WinIOError(Int32 errorCode, String str) | at ExceptionManagementQuickStartSampl
Non-Matches ExceptionManagementQuickStartSamples.Form1.DoLogon(String userName, String password) in c:\program f

Expression (NOT)?(\s*\(*)\s*(\w+)\s*(=|&lt;&gt;|&lt;|&gt;|LIKE|IN)\s*(\(([^\)]*)\)|'([^']*)'|(-?\d*\.?\d+))(\s*\)*\s*)(AND|OR)?
Description Heres my sql clause parser regexp for recordset filtering. Does recursive query parsing all by its self. Only problem I cant figure is how to match comma separated lists of quoted strings. Tell me if you figure out how! The unicodes in the re was put in by the entry form please replace them with their ascii equivalents to use it.
Matches Aeroplane LIKE 767 | Movie LIKE 'Star' AND NOT Movie LIKE 'Trek' | Number IN (1,2,3,4,5)
Non-Matches Hello there | A=EXCELLENT OR | B!=POOR

Expression ^(.|\n){0,16}$
Description Limit Length - limit the length of a text box or other area to contain any character plus new line
Matches shorter than max
Non-Matches string longer than max

Expression (?s)(?:\e\[(?:(\d+);?)*([A-Za-z])(.*?))(?=\e\[|\z)
Description This expression will match all of the commands(escape codes) used in ANSI files. These are what were used to create the colors/blocks on BBS's for those of us that once dialed into them. http://www.wikipedia.org/wiki/ANSI_escape_code has a reference for ANSI escape codes. http://idledreams.net/lordscarlet/posts/153.aspx shows an example of the engine I have created surrounding the expression
Matches [32mHello | [1;35mTest | [2J
Non-Matches abc

Expression ^[a-zA-Z_][a-zA-Z0-9_]*$
Description Matches variable names/identifier from C# (and most other languages)
Matches VariableName | i | Some_Value_3
Non-Matches 3ID | Hello World

Expression ^[{|\(]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[\)|}]?$
Description Specifier Format of Guid Values that this RegEx supports: 32 digits: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 32 digits separated by hyphens: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx] 32 digits separated by hyphens, enclosed in brackets: [{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}] 32 digits separated by hyphens, enclosed in parentheses: [(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]
Matches 914D226A-2F5B-4944-934D-96BBE6571977 | {914D226A-2F5B-4944-934D-96BBE6571977}
Non-Matches 914D226A-2F5B-4944-XXXX-96BBE6571977 | {914D226A-2F5B-4944-XXXX-96BBE6571977}

Expression ^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$
Description This matches an IP address, putting each number in its own group that can be retrieved by number. If you do not care about capturing the numbers, then you can make this shorter by putting everything after ^ until immediately after the first \. in a group ( ) with a {3} after it. Then put the number matching regex in once more. It only permits numbers in the range 0-255.
Matches 0.0.0.0 | 255.255.255.02 | 192.168.0.136
Non-Matches 256.1.3.4 | 023.44.33.22 | 10.57
============================================================================================
Address/Phone
============================================================================================
Expression^0[234679]{1}[\s]{0,1}[\-]{0,1}[\s]{0,1}[1-9]{1}[0-9]{6}$
Description The regex matches the UAE land phone numbers. Checks the area codes[04,02,06...etc] strictly. Force user to input phone numbers in strict manner(it take input 04 3452488, but not 04______spaces_______3452488)
Matches 04 3452488 | 04 -3452488 | 04 - 3452499
Non-Matches 01 -3452488 | 04 34524888 | 08 3452488

Expression (^(?!0{5})(\d{5})(?!-?0{4})(-?\d{4})?$)
Description Javascript matches US zipcodes not allowing all zeros in first 5 or +4
Matches 12345 | 12345-6789 | 123456789
Non-Matches 12345-0000 | 00000-0000 | 00000

Expression ^[a-zA-Z0-9&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#216;&#217;&#218;&#219;&#220;&#221;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#241;&#242;&#243;&#244;&#245;&#246;&#248;&#249;&#250;&#251;&#252;&#253;&#255;\.\,\-\/\']+[a-zA-Z0-9&#192;&#193;&#194;&#195;&#196;&#197;&#198;&#199;&#200;&#201;&#202;&#203;&#204;&#205;&#206;&#207;&#208;&#209;&#210;&#211;&#212;&#213;&#214;&#216;&#217;&#218;&#219;&#220;&#221;&#223;&#224;&#225;&#226;&#227;&#228;&#229;&#230;&#231;&#232;&#233;&#234;&#235;&#236;&#237;&#238;&#239;&#241;&#242;&#243;&#244;&#245;&#246;&#248;&#249;&#250;&#251;&#252;&#253;&#255;\.\,\-\/\' ]+$
Description This simple regexp should match any possible italian address entry and doesn't match NULL entries (good if address is required). Should work well for any other address (it's been verified against 250 addresses from most european countries, usa and australia. Please mail me if there's something missing
Matches v.le dell'industria 45/a | via genova 45-3-d | p.zza Garibaldi, 48
Non-Matches [NULL]

Expression ^[0-9]{2,3}-? ?[0-9]{6,7}$
Description Validates Spain Phones
Matches 972367087 | 97-3770866 | 972-377086
Non-Matches 9988-989898 | 989898988989 | 9 9898989898


Expression ^[1-9][0-9]{3}\s?[a-zA-Z]{2}$
Description Validates Dutch Postal Codes (ZipCode). There was a previous one listed here, but it's not entirely correct. Namely that dutch postal codes can contain a zero but cannot start with one, so this one is the adjusted version.
Matches 1234AB | 1234 AB | 1001 AB
Non-Matches 0123AB | 1234A B | 0123 AB

Expression ^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$
Description This regular expressions matches phone numbers with area codes and optional US country code and optional phone extension. User have so many ways of entering phone numbers into input fields. This allows for some of the ones I've encountered. Feel free to contact me if you find ones that do not match.
Matches 2405525009 | 1(240) 652-5009 | 240/752-5009 ext.55
Non-Matches (2405525009 | 2 (240) 652-5009

Expression ^[0-9]{5}$
Description Matches german standard postal codes named 'Postleitzahl'
Matches 03242 | 36260 | 12394
Non-Matches 3520 | 102 | 100202

Expression ^(?-i:A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$
Description The RE match U.S. state abbreviation used by the U.S. Post Office.
Matches AL | CA | AA
Non-Matches New York | California | ny
Author Rating: Michael Ash

Description I know its probaly in the library, but i did not see it. US zip pattern 5 digits 01234 or 5 digits + 4 01234-1234
Matches 12345 | 12345-6789 | 01234
Non-Matches 1A234 | 12345-aaaa | 12345 1234

Expression ^([0-9]*\-?\ ?\/?[0-9]*)$
Description Match italian telephone number with prefix followed by &quot;/&quot;, &quot;-&quot; or blank and number. Usefull with numeric keybord!
Matches 02-343536 | 02/343536 | 02 343536
Non-Matches 02a343536 | 02+343536

Expression ^((\d{5}-\d{4})|(\d{5})|([A-Z]\d[A-Z]\s\d[A-Z]\d))$
Description This expression matches three different formats of postal codes: 5 digit US ZIP code, 5 digit US ZIP code + 4, and 6 digit alphanumeric Canadian Postal Code. The first one must be 5 numeric digits. The ZIP+4 must be 5 numeric digits, a hyphen, and then 4 numeric digits. The Canadian postal code must be of the form ANA NAN where A is any uppercase alphabetic character and N is a numeric digit from 0 to 9.
Matches 44240 | 44240-5555 | T2P 3C7
Non-Matches 44240ddd | t44240-55 | t2p3c7

Expression ^[A-Za-z]{1,2}[\d]{1,2}([A-Za-z])?\s?[\d][A-Za-z]{2}$
Description UK Postal Codes - The code is normally written in capital letters with a space between the outer and inner parts; it is understandable if the space is omitted. This regular expression validates upper or lower case with or without the space:
Matches CF1 2AA | cf564fg
Non-Matches a1234d | A12 77Y

Expression ^[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}(\-| |){1}[0-9]{1}[a-zA-Z]{1}[0-9]{1}$
Description This expression will help match Quebec's postal codes.
Matches h2j-3c4 | H2J 3C4 | H2J-3c4
Non-Matches H2J_3C4 | H213C4 | 123456

Expression \b((?:0[1-46-9]\d{3})|(?:[1-357-9]\d{4})|(?:[4][0-24-9]\d{3})|(?:[6][013-9]\d{3}))\b
Description This is my attempt to find out valid german postal codes (PLZ or Postleitzahlen). After the German Unification the numbers were changed to a five digit system. The postal codes starts with the two digit &quot;Leitzahl&quot;. This is a number between 00 and 99 excluding the not yet used numbers: 00, 05, 43 and 62! After that follows directly a three digit number, 000-999. Comments welcome. This works for me, however I think it could be written more compact, but could not figure out how ;-) For more information on german postal codes see: http://de.wikipedia.org/wiki/Liste_der_Postleitbereiche_Deutschland http://de.wikipedia.org/wiki/Postleitzahl_%28Deutschland%29 http://en.wikipedia.org/wiki/List_of_postal_codes_in_Germany
Matches 12556 | 01550 | 80796
Non-Matches 05234 | 8973 | 62980

Expression ^[1-9]{1}[0-9]{3}\s?[A-Z]{2}$
Description Postcode for the Netherlands
Matches 1234AB | 1234 AB
Non-Matches 123BBB | 023AB

Expression ^[+][0-9]\d{2}-\d{3}-\d{4}$
Description This is a basic telephone number vaildation which needs a compulsory prefix of a '+' sign with three digits and followed by a hipen, another three digits and finally followed by another hipen and four more digits. Regards, Senthil Gunabalan
Matches +974-584-5656 | +000-000-0000 | +323-343-3453
Non-Matches 974-584-5656 | +974 000 0000

Expression (^1300\d{6}$)|(^1800|1900|1902\d{6}$)|(^0[2|3|7|8]{1}[0-9]{8}$)|(^13\d{4}$)|(^04\d{2,3}\d{6}$)
Description Australian phone numbers: Matches all known formats incl normal 10-digit landline numbers (valid area code mandatory) 13, 1300, 1800, 1900, 1902 plus mobile 10 and 11-digit formats. Use a Replace function first to remove non-numerics which are probably separators (E.g. newNum = number.replace(/[\D]/g, &amp;quot;&amp;quot;). Please contact me if you find any valid Aussie numbers being rejected.
Matches 0732105432 | 1300333444 | 131313
Non-Matches 32105432 | 13000456

Expression ^[0-9]{6}
Description I know its simple, yet there was no Russian postal code regular expression on the RegExLib. Just in case some needs to know the format.
Matches 150016
Non-Matches qqww

Expression ^[abceghjklmnprstvxyABCEGHJKLMNPRSTVXY][0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ] {0,1}[0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ][0-9]$
Description Canadian Postal Code / Codes / Canada / Zip Google for DFIOQU and you'll see where I got the info for this. Can anyone simplify this?
Matches G3M 5T9 | C3M5T9
Non-Matches Z3M 5T9 | W3M 5T9 | 5T9 C3M

Expression ^(\()?(787|939)(\)|-)?([0-9]{3})(-)?([0-9]{4}|[0-9]{4})$
Description Filter US telephone numbers. This particular one accepts only area code 939 or 787. Area code parentesis or hyphens optional.
Matches (787)755-0114 | 939-315-0112 | 7879093849
Non-Matches (098)737-3942
=====================================================================
Markup code
=====================================================================
Expression (<\/?)(?i:(?<element>a(bbr|cronym|ddress|pplet|rea)?|b(ase(font)?|do|ig|lockquote|ody|r|utton)?|c(aption|enter|ite|(o(de|l(group)?)))|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|rame(set)?)|h([1-6]|ead|r|tml)|i(frame|mg|n(put|s)|sindex)?|kbd|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|script)|o(bject|l|pt(group|ion))|p(aram|re)?|q|s(amp|cript|elect|mall|pan|t(r(ike|ong)|yle)|u(b|p))|t(able|body|d|extarea|foot|h|itle|r|t)|u(l)?|var))(\s(?<attr>.+?))*>
Description This RE will match all the valid elements in HTML 4.01
Matches <HTML> | <a href="link.html">Link</a>
Non-Matches <xml> | <phonytag> | <image>

Expression (?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit)))
Description This regex will match all the valid on event attributes in HTML 4.01/XHTML 1.0
Matches onclick | onsubmit | onmouseover
Non-Matches click | onandon | mickeymouse

Expression ^#?(([fFcC0369])\2){3}$
Description Matches the 216 web colors with or without the '#' sign.
Matches #FFFFFF | FFCC00 | 003300
Non-Matches #FFFFF | EFCC00 | 030303

Expression (\[(\w+)\s*(([\w]*)=('|&quot;)?([a-zA-Z0-9|:|\/|=|-|.|\?|&amp;]*)(\5)?)*\])([a-zA-Z0-9|:|\/|=|-|.|\?|&amp;|\s]+)(\[\/\2\])
Description Peseudo-HTML code matcher. Allows for one parameter within the first tag (name is optional), the value of which can be optionally delimited by either double or single quotes. Uses backreferencing to ensure that the end and start tags match, and that any single or double quotes match. Very useful for web forums or any situation where users may be prompted to enter text for display on a webpage somewhere, as it can be quickly processed into HTML without allowing HTML to be specified within the input itself (which may pose a security risk).
Matches [link url=&quot;http://www.domain.com/file.extension?getvar=value&amp;secondvar=value&quot;]Link[/li
Non-Matches [a]whatever[/b] | [a var1=something var2=somethingelse]whatever[/a] | [a]whatever[a]

Expression (?'openingTag'&lt;) \s*? (?'tagName'\w+) # Once we've got the tagname, match zero # or more attribute sequences (\s*? # Atomic Grouping for efficiency (?&gt; (?!=[\/\?]?&gt;) # Lookahead so that we can fail quickly # match Attribute pieces (?'attribName'\w+) (?:\s* (?'attribSign'=) \s* ) (?'attribValue' (?:\'[^\']*\'|\&quot;[^\&quot;]*\&quot;|[^ &gt;]+) ) ) )* \s*? # Closing Tag can be either &gt; or /&gt; (?'closeTag'[\/\?]?&gt;)
Description Matches and segments the sections of an opening tag. For more detailed information refer to this blog entry: http://weblogs.asp.net/dneimke/posts/25616.aspx
Matches &lt;head&gt; | &lt;script language=javascript&gt; | &lt;input type=submit &gt;
Non-Matches &lt;/head&gt;

Expression &lt;!--.*?--&gt;
Description
Matches &lt;!-- &lt;h1&gt;this text has been removed&lt;/h1&gt; --&gt; | &lt;!-- yada --&gt;
Non-Matches &lt;h1&gt;this text has not been removed&lt;/h1&gt;

Expression ^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$
Description A general string validation to insure that NO malicious code or specified characters are passed through user input. This will allow you to input any characters except those specified. The expression above does not allow user input of &lt;&gt;`~!/@\#}$%:;)(_^{&amp;*=|'+. Input as many invalid characters you wish to deny. This really works!
Matches This is a test
Non-Matches <href = | <br> | That's it

Expression &lt;!--[\s\S]*?--[ \t\n\r]*&gt;
Description As I could understand the HTML standard, this is the valid reg.exp. for comments. The only differenc from the last one is that the comment can be terminated by two minuses followed by none OR SOME space caracters and then by character &gt;
Matches &lt;!-- anything -- &gt; | &lt;!-- anything -&gt; -&gt; --&gt;
Non-Matches &lt;!-- something -- and more &gt;

Expression (SELECT\s[\w\*\)\(\,\s]+\sFROM\s[\w]+)| (UPDATE\s[\w]+\sSET\s[\w\,\'\=]+)| (INSERT\sINTO\s[\d\w]+[\s\w\d\)\(\,]*\sVALUES\s\([\d\w\'\,\)]+)| (DELETE\sFROM\s[\d\w\'\=]+)
Description This RE match the SQL Basics Queries (SELECT, UPDATE, INSERT and DELETE).
Matches SELECT * FROM TABLE | UPDATE TABLE SET FIELD=VALUE WHERE ID_FIELD=VALUE_ID | DELETE FROM TABLE WHERE
Non-Matches SELECT TABLE | UPDATE SET TABLE | INSERT INTO FIELD=VALUE TABLE

Expression \{\\\*\\bkmkstart\s(.*?)\}
Description Applied to a .RTF document, returns all the names of the# bookmarks. Useful to retrieve# dinamically# the list of bookmarks from a document.
Matches {\*\bkmkstart TagAmountDigits} | ({\*\bkmkstart TagAmountText}
Non-Matches {\*\bkmkend TagAmountText}

Expression (?<commentblock>((?m:^[\t ]*\/{2}[^\n\r\v\f]+[\n\r\v\f]*){2,})|(\/\*[\w\W]*?\*\/))
Description This expression will match comment blocks in javascript, c, c++, etc I wrote this as a named group called &quot;commentblock&quot;, as I like to use it with other expressions. It avoids single line comments or inline commented code (which are not considered comment &quot;blocks&quot;) unless the comments are in a /* text */ comment style could not create a multiline example in the matching examples, here is what I tried to enter // Some text //(must be two or more lines long and each line may only be preceded by whitespace)
Matches /* Some text (may be any number of lines) */
Non-Matches // Some text (only a single line) | Some code // comment here (even if next line has comment) | /* S

Expression &amp;(?![a-zA-Z]{2,6};|#[0-9]{3};)
Description The goal of this regular expression is to replace all &amp; (ampersand) characters by &amp;amp; if they are not the start of HTML entities. I used http://www.w3schools.com/html/html_entitiesref.asp as a reference. You can then use RegExp Replace method to do the work. Was helpful for me, might helpful be for you...
Matches &amp;ThisIsTooLong; | Lilo &amp; Stich | &amp;l;
Non-Matches &amp;lt; | &amp;brvbar; | &amp;#166;

Expression ^(\x22|\x27)((?!\1).|\1{2})*\1$
Description The regex validate a quoted string in VBScript or Ansi SQL. The string may contain the containing quote character if it is escaped by being doubled up. In VB/VBScript two double quotes within a string enclosed in double qoutes translate into one double quote within the string In SQL two single quotes within a string enclosed in single qoutes translate into one single quote within the string
Matches "To quote Yoda (""Do, or do not. There is no 'try'"" )"
Non-Matches 'This won't validate' | "He said "Ok.""

Expression & (?ni:\# # if a pound sign follow ampsand look for number ((x # if x follow pound sign accept hex value up to 5 digits ([\dA-F]){1,5} ) | # otherwise accept decimal number between 0 - 1048575 (104857[0-5] |10485[0-6]\d |1048[0-4]\d\d |104[0-7]\d{3} |10[0-3]\d{4} |0?\d{1,6}) ) | # no pound sign after ampersand ([A-Za-z\d.]{2,31}) #accept ASCII alphanumeric and period ); #end with semi-colon.
Description This regex can be used to find general entites in HTML, XML and SGML files. The entity can consist of 1) an ampsand (&amp;) 2) followed by (a) ASCII alphanumerics or period between 2 and 31 characters or (b) a pound sign # (i) followed by an x followed by a unicode value up to 5 hex digits or (ii) followed by a decimal value from 0 to 1048575 3) ending with a semi-colon (;)
Matches &quote; | &#169; | &#x00027;
Non-Matches & | &#Hello; | &#Xray;

Expression ^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$
Description Tests for valid HTML hexadecimal color codes. The # symbol is optional. And it will except either the 3 digit form for the 216 Web safe colors, or the full 6 digit form. I am use it on my site to allow users to customize the site's colors.
Matches #00ccff | #039 | ffffcc
Non-Matches blue | 0x000000 | #ff000

Expression ^(?<Code>([^"']|"[^"]*")*)'(?<Comment>.*)$
Description This expression separates a Visual Basic (VB) source code line into the code part and the comment part (if any, following an apostrophe character not enclosed in quote marks).
Matches a = b ' Comment | a = "xy'z" ' Comment
Non-Matches a = b | rem not supported

Expression &lt;!--[\s\S]*?--&gt;
Description Removes pesky comments and commented javascript from HTML
Matches &lt;!-- comments --&gt; | &lt;!-- x = a &gt; b - 3 --&gt;
Non-Matches &lt;COMMENTS&gt;this is a comment&lt;/COMMENTS&gt;

Expression <(?<tag>.*).*>(?<text>.*)</\k<tag>>
Description Match the content of any regular tag/s
Matches <body>Content here</body>
Non-Matches <body>Content here<body>

Expression ('.*$|Rem((\t| ).*$|$)|&quot;(.|&quot;&quot;)*?&quot;)
Description Pulls out comments (both Rem and ') and string literals from VB or VBScript. Usefull for spell checking or review. Notes: The VBScript for &quot;Rem&quot; documentation says that it must be followed by a space but VBScript seems to accept tab characters as well. The multiline flag is assumed for this search.
Matches ' This is a comment | Rem This is a comment | &quot; This is a string with &quot;&quot; and ' &quot;
Non-Matches &quot; This is not a string | RemThis is not a comment | This is not a comment or a string

Expression href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\']
Description I wrote up this regular expression to fetch the href attribute found in &lt;a&gt; tags as well as a few other HTML tags.
Matches href="www.yahoo.com" | href="http://localhost/blah/" | href="eek"
Non-Matches href="" | href=eek | href="bad example"