-2

new to regex, is there a way to determine files having no extension?

Also need another one for .zip files

(//).test(files[i])
user2727195
  • 7,122
  • 17
  • 70
  • 118

1 Answers1

0

The best way to get extentions I've found is from: How can I get file extensions with JavaScript?. This isn't regex, but you don't need regex - so unless this is a learning exercise, I'd go with string-based functions.

With that in hand you can check for blank as:

if(filename.substr((~-filename.lastIndexOf(".") >>> 0) + 2).length==0)

and for zips as:

if(filename.substr((~-filename.lastIndexOf(".") >>> 0) + 2)=="zip")

Check out that other post, if you definitely want regex - there are a couple good ones in there.

Community
  • 1
  • 1
netricate
  • 1,708
  • 2
  • 12
  • 13