Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String DiscoverCreditCardPattern = "^6(?:011|5[0-9]{2})[0-9]{12}$"; private static boolean isDiscoverCard(String creditCardNumber) { Pattern pattern = Pattern.compile(DiscoverCreditCardPattern); Matcher matcher = pattern.matcher(creditCardNumber); return matcher.find(); } }