How to make a regex that matches only r.js or build.js, but not to router.js (for example)?I did this: /^r.js$|^build.js$/ , but I feel there is a way to remove ^ and $. If I delete them, router.js will match.
/^r.js$|^build.js$/
Try:
/^(r|build)\.js$/
'' should be avoided. If ^ is deleted, it will match router.js, if $ is removed, it will match r.jsx. Therefore, they are necessary.