如何在Express.js中创build“不以…开头”正则expression式?

app.get('if it does not begin with /api', function(req,res){ //the path does not begin with "/api" }); 

我怎么写这个正则expression式?

您应该将JavaScript用作正常的正则expression式,并带有负面的前瞻性。 尝试这个:

 app.get(/^(?!\/api).+/, function(req,res){ //the path does not begin with "/api" });