Monday, 9 September 2013

Regex to match paths that don't match a specific pattern: Express Router

Regex to match paths that don't match a specific pattern: Express Router

I want to ignore all paths of the form /foo/* on my express server. So I
want to do
app.get('someRegexThatDoesntMatchFoo/*', routes.index)
I have tried
app.get('/^\(\(.*foo/.*\)\@!.\)*$', routes.index);
but that didnt work-- it doesn't catch all-routes-besides-foo and apply
routes.index instead i get a CANNOT GET bar for any /bar request
Any suggestions?
Thanks!

No comments:

Post a Comment