-3

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
  • 6,249
  • 6
  • 28
  • 36

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
  • 19,238
  • 3
  • 22
  • 49