-2

What will be the regular expression to accept all type of file formats except zip format?

.*

accepts all types of files. But I don't want zip files. So what will be regex in this case?

Thanks.

Tula
  • 307
  • 6
  • 15

1 Answers1

2

You just need to use a negative lookahead to ensure your input doesn't end with .zip for which you can use this regex,

^(?!.*\.zip$).+$

Demo

Here ^ and $ match start and end of line and (?!.*\.zip$) negative lookahead ensures it doesn't match a text ending with .zip and .+ matches any character one or more.

Silvanas
  • 613
  • 3
  • 11