-1

I have the following regex expression being used in a JavaScript function.

regex = /(([a-zA-Z]{3})+([0-9]{12})+(.zip))$/g; 

I want the last characters (.zip) also as case insensitive. How to achieve this ? Thanks

venkat14
  • 583
  • 3
  • 12
  • 34

1 Answers1

2

Use i modifier

var regex = /(([a-z]{3})+([0-9]{12})+(\.zip))$/ig; 
var str="abAc772345678989.ZIP";
console.log(regex.test(str))
ellipsis
  • 12,049
  • 2
  • 17
  • 33
  • 1
    Why not use the `i` flag simply? Also, the `.` before the `zip` in the regex will match any character except newline. Not just `.` – Gurmanjot Singh Feb 15 '19 at 06:10
  • 1
    OP says "case-insensitive" so to be thorough, you'd need to handle "ZiP", "zIP", "ZIp", etc – Phil Feb 15 '19 at 06:10