Node.js Express JS-正则表达式-除

Node.js Express JS-正则表达式-除,node.js,regex,express,Node.js,Regex,Express,我正在使用ExpressJS4.x开发RESTWeb服务器。 我试图做的是编写一个中间件来捕获所有传入的请求,除了那些以“/api/…”开头的请求 我可以使用哪个正则表达式 //This middleware catches everything except the requests addressed to "/api/..." app.use('<regular_expression>',express.static('public')); //Not intercepted

我正在使用ExpressJS4.x开发RESTWeb服务器。 我试图做的是编写一个中间件来捕获所有传入的请求,除了那些以“/api/…”开头的请求

我可以使用哪个正则表达式

//This middleware catches everything except the requests addressed to "/api/..."
app.use('<regular_expression>',express.static('public'));

//Not intercepted by the middleware
app.get("/api/foo1",function(req,res)=>{
    ......
})

//Not intercepted by the middleware
app.get("/api/foo2/bar",function(req,res)=>{
    ......
})
//此中间件捕获除发送到“/api/”的请求之外的所有内容
应用程序使用(“”,express.static('public'));
//没有被中间件拦截
app.get(“/api/foo1”,函数(req,res)=>{
......
})
//没有被中间件拦截
app.get(“/api/foo2/bar”),函数(req,res)=>{
......
})
根据这一点,您可以使用(它们在中提供):


如您所见,正则表达式没有引号。

这正是我在生产中使用的正则表达式。所以我可以确认这也行。
app.use(/\/((?!api).)*/, app_lookup);