0

/* regular expression */

Regex regex = new Regex(@"^[a-zA-Z]\d{16}$");

/*expression validation */

if ((regex.IsMatch(this.CreditCardNumber)))
{
    // Error message to display
    result = false;
}

eg

AX411111111111111

above expression not working in C# any suggestions?

ckshah
  • 3
  • 5
  • 1
    `new Regex(@"^[A-Za-z]{2}\d{16}$");` ? – Tim Biegeleisen Oct 16 '17 at 02:25
  • Regex regex = new Regex(@"^\s * (?=.*[1 - 9])\d +[,\.\d] +$"); if (!(string.IsNullOrEmpty(val))) { if (!(regex.IsMatch(val))) { return res; } Having textbox which accepting amount in strict format -> should support up to 99999.99.For that above regex i have created but not working..I need help on this. – ckshah Oct 19 '17 at 01:56

1 Answers1

0

The example you have given has only 15 digits, if you put 16 digits on it, it should work with this ^[a-zA-Z]{2}[0-9]{16}$ or with Tim's suggestion.

stevenferrer
  • 2,504
  • 1
  • 22
  • 33