-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

1
  • 3
    /(([a-z]{3})+([0-9]{12})+(\.zip))$/gi Commented Feb 15, 2019 at 6:07

1 Answer 1

2

Use i modifier

var regex = /(([a-z]{3})+([0-9]{12})+(\.zip))$/ig; 
var str="abAc772345678989.ZIP";
console.log(regex.test(str))

Sign up to request clarification or add additional context in comments.

2 Comments

Why not use the i flag simply? Also, the . before the zip in the regex will match any character except newline. Not just .
OP says "case-insensitive" so to be thorough, you'd need to handle "ZiP", "zIP", "ZIp", etc

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.