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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^([51|52|53|54|55]{2})([0-9]{14})$
Description
Validate against any mastercard number. All MC's start with a number between 51 and 55 and are followed by 14 other numbers.
Matches
5125632154125412 | 5225632154125412 | 5525632154125412
Non-Matches
5625632154125412 | 4825632154125412 | 6011632154125412
Author Rating: The rating for this expression. Jeff Johns
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: Yell's code
Name: Nate
Date: 4/18/2008 3:42:32 PM
Comment:
My apologies Yell, your code does work, the fault was mine with having a whitespace I did not notice at the end (and I didn't notice that yours does check for an end of string).


Title: Yell's code
Name: Nate
Date: 4/17/2008 4:41:55 PM
Comment:
Yell, your code fails to pass the valid card 5199999999999999


Title: False Positive
Name: Nate
Date: 4/17/2008 4:26:14 PM
Comment:
It appears to match anything that contains 2 of the numbers listed. So it matches 15, 24, 35, 31, 43 and so on, so long as both of the numbers appear at least once in 51|52|53|54|55.


Title: This is a better one
Name: YeLL
Date: 3/2/2008 7:53:17 AM
Comment:
^5[1-5][0-9]{14}$


Title: False Positive
Name: Paul
Date: 6/28/2005 4:04:21 PM
Comment:
Why does this match ? 1599999999999999


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