-1

Using regex, I'm trying to check whether there's only 2-4 characters used after a .. At the moment, i got it working to detect when its less than 2 characters but after 4 characters, it still deems it as successful. How can I fix this? This is what I have written down:

/.[a-zA-Z]{2,4}$/
Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476

2 Answers2

0

You need to escape the dot (.).

/\.[a-zA-Z]{2,4}$/
plalx
  • 41,415
  • 5
  • 69
  • 87
-1

. is the control character in RegExp, you should to escape it:

/\.[a-zA-Z]{2,4}$/

And, to ignore case, add the i flag:

/\.[a-z]{2,4}$/i
devdb
  • 49
  • 3