Skip to content

Instantly share code, notes, and snippets.

View LionC's full-sized avatar

Leon Strauss LionC

View GitHub Profile
@LionC
LionC / CardType.java
Last active June 8, 2021 06:52 — forked from gabrielbauman/CardType.java
A Java enum representing credit card types (Visa, Mastercard etc) that can detect card type from a credit card number.
package com.gabrielbauman.gist;
import java.util.regex.Pattern;
public enum CardType {
UNKNOWN,
VISA("^4[0-9]{12}(?:[0-9]{3})?$"),
MASTERCARD("^5[1-5][0-9]{14}$"),
AMERICAN_EXPRESS("^3[47][0-9]{13}$"),