I want exclude paths which contains ‘locale’ and ‘test’ before extension. Paths can contain dots.
branch.name/packages/components/filename.js – true
branch.name/packages/components/filename.locale.js – fail
branch.name/packages/components/filename.test.js – fail
branch.name/packages/components/filename.utils.js – true
2
Answers
You may call
test()
using the regex pattern:This matches
test
orlocale
followed by any extension at the end of the file.If you require at least one word character after a period to qualify as an extension,
^(?!.*(?:locale|test).w)
will work.