RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find CVV2/CVC2/CID
Expression
^(?!000)\d{3,4}$
Description
This is a bit shorter than the first CVV2/CVC2/CID regex found on the site. It matches any 3 or 4 character number. Now featuring change per suggestion in comments. Thanks!
Matches
123 | 1234
Non-Matches
1 | 12 | 12345
Author Rating: The rating for this expression. Tony Fugere
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: will match mis-formed entries
Name: Cory Hubbert
Date: 8/8/2011 11:59:55 AM
Comment:
1a223 will match 1223, may want ^(?!000)\d{3,4}$ which will not match this.


Title: 000 and 0000 are valid CVV2 numbers
Name: Ian Lotinsky
Date: 11/19/2009 10:55:38 AM
Comment:
We just ran into 000 and 0000 CVV2s yesterday. Can you reference your source @osizzle? Thanks.


Title: CVV2/CVC2/CID
Name: osizzle
Date: 9/28/2007 4:39:36 PM
Comment:
You can add the following and it will stop people from putting in 000 or 0000 which are invalid codes: (?!000)\d{3,4}$


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials