Home > other >  Glob pattern to match filenames that does not have "." character
Glob pattern to match filenames that does not have "." character

Time:02-03

What is the glob pattern to include filenames that end with .test.js but do not include filenames with additional . characters?

For example:

deviceFilter.test.js                      //pass
deviceFilter.offline.test.js              //fail
deviceFilter.nodata.test.js               //fail
deviceFilter.offline.nodata.test.js       //fail

With regex one can do ^[^.]*.test.js$ to achieve this. Is there any glob pattern equivalent? I have tried *(!.)*.test.js but this still passes all the examples above.

CodePudding user response:

I think this should work for you

 (!(*.*)).test.js

Tested with this tool

  •  Tags:  
  • Related