Java regex: Negative lookahead
I'm trying to craft two regular expressions that will match URIs. These URIs are of the format: /foo/someVariableData and /foo/someVariableData/bar/someOtherVariableData I need two regexes. Each needs to match one but not the other. The regexes I originally came up with are: /foo/.+ and /foo/.+/bar/.+ respectively. I think the second regex is fine. It will only match the second string. The first regex, however, matches both. So, I started playing around (for the first time) with negative lookahead. I designed the regex /foo/.+(?!bar) and set up the following code to test it public static void