
June 2, 2010 08:17 by
using System.Text.RegularExpressions;
public string CheckCC(string ccNumb){
//reg expression checks to see if the value in ccNum "LOOKS" like a valid cc number
//will return invalid if there are non num chars or the string is not the correct length
// checks for visa MC, amex, diners club, jcb and discover
string ccRegEx = @"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$";
Regex r = new Regex(ccRegEx, RegexOptions .IgnoreCase);
// Match the regular expression pattern against the cc text string.
Match m = r.Match(ccNum);
if (!m.Success ) return "CC number is invalid" ;
}
dc124962-7fa9-4e2f-901c-7908c3ad2cac|1|5.0