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