views:

225

answers:

1

In my application which uses spring security I want to define two different areas both using their own spring security filter-chain. My question is: is it possible to define two regex expressions as follows:

  1. every path starting with /foobar/*
  2. every other path not starting with /foobar

The important part here is that the second path should also match if somewhere within it, but not in the beginning, it cotains the /foobar/ string.

Thanks

+1  A: 
^/foobar/.*$

will match if the path starts with /foobar/;

^(?!/foobar/).*$

will match any path that doesn't start with /foobar/ ((?!...) is a so-called negative lookahead assertion).

Tim Pietzcker