Reputation: 619
I'm looking for a reg. expression to match all *.js files in my /lib directory except for (for example) jquery.js and require.js.
^(\/lib/)([^\/]*)$
the above only selects all the .js files inside the lib directory but I'm not sure where to define the exclude part.
/lib/jquery.js
/lib/handlebars.sj
/librequire.js
/lib.test.js
Upvotes: 3
Views: 6127
Reputation: 95958
Try this regex* (if I understood you correctly):
\/lib\/(?!jquery|require).*\.js
It matches all .js
files inside /lib/
directory except jquery.js
and require.js
.
This is called negative lookahead, it's used when you want to match something not followed by something else.
Note that this regex does not match anything that start with jquery
or require
(after /lib/
), if you want so, you can easily bound the wanted words.
* I don't think regex is your best approach for this problem
Upvotes: 9