Search code examples
regexgoogle-search-appliancere2

Match last directory of URL with RE2 regex


For the standard GSA frontend, I'd like to filter on directory the result is in and I'd do this with entity recognition.

This regex matches exactly that: [^/]+(?=/[^/]+$) but it does not satisfy the RE2 syntax required by the GSA.

Is it possible to use the lookahead differently or does anyone know a valid RE2 substitute?

thanks


Solution

  • Acc. to https://re2.googlecode.com/hg/doc/syntax.html, the lookaheads are not supported. Use just capturing groups:

    ([^/]+)(?:/[^/]+$)