Usage var regex = require('{%= name %}'); 'a/b/c/d.min.js'.match(regex()); //=> match[0] = 'd.min.js' 'a/b/c/.dotfile'.match(regex()); //=> match[0] = '.dotfile'