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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^5[1-5][0-9]{14}$ # First character is 5 # Second character is 1-5 # Last 14 characters 0-9
Description
Validates Mastercard credit card
Matches
5125632154125412 | 5225632154125412 | 5525632154125412
Non-Matches
5625632154125412 | 4825632154125412 | 1599999999999999
Author Rating: The rating for this expression. Ben Parish
Source Taken from article on sitepoint.com by Mitchell Harper and David Rusik
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: Not valid any more
Name: Ahma Ansari
Date: 7/22/2019 7:56:01 AM
Comment:
Mastercard series has been updated, and cannot start with 2 also, see following regex: ^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$


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