Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String AmericanExpressCreditCardPattern = "^3[47][0-9]{13}$"; private static boolean isAmericanExpress(String creditCardNumber) { Pattern pattern = Pattern.compile(AmericanExpressCreditCardPattern); Matcher matcher = pattern.matcher(creditCardNumber); return matcher.find(); } }