-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,791
  • 5
  • 29
  • 34

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
  • 17,055
  • 2
  • 18
  • 45