I'm trying to create a "Azure front door" compliant regex that matches /users/*
URL pathname patterns. But not /users/*/
or /users/*/profile
or /users/*/<anything at all>
I've tried without escaping as it looks like front door escapes for you.
^/users/([^/]+?)(?:/)?$
and this
^/users/[^/]+?$
But this doesn't work, I'm assuming because of the "?" which would count as a back reference? Any ideas on how to create a compliant regex, happy to try anything for anyone who doesn't have front door to test.
=== EDIT ===
Iv'e accepted the below answer, but I think the culprit is RegEx's matching a preceeding "/", every other operator in front door rules seems to want a preceeding "/" except RegEx, without this it seems to work as expected in some basic testing.
With this in mind I've accepted the below answer but I have a feeling (without trying) that some of the original formats will work.
You need to use
^users/[^/\s]+$
without a leading slash when matching against the Request
path
.
Details
^
- start of string/users/
- a fixed string[^/\s]+
- one or more chars other than /
and whitespace$
- end of string.