-2

I need a regular expression which accepts following format 1111A or 1234B.

I used /([0-9]{0,4})&([A-Z])/ but not able to get it.

Biffen
  • 5,354
  • 5
  • 27
  • 32

1 Answers1

0

Try using ^\d{4}[A-Z]$

const re = RegExp(/^\d{4}[A-Z]$/);
console.log(re.test('1111A'));
console.log(re.test('1A111'));
console.log(re.test('1111AA'));
Nitheesh
  • 6,950
  • 1
  • 12
  • 31