Regular Expression match URL starting with a path but excludes one or more subpaths

Viewed 18

I'm trying to match a URL in PHP where all paths starting with a path matches but excludes a subpath. For example I want to match any paths starting with /admin but not match paths starting with /admin/auth.

Example path to match: /admin/dashboard

Example path not to match: /admin/auth/login

What I've tried but doesn't work: #^/admin(?<!/auth)/.*$#

1 Answers
Related