Welcome Guest, Not a member yet? Register   Sign In
Regex for group names requires an '/'

(This post was last modified: 04-09-2023, 11:44 PM by martin_ci.)

Hi there!
I'd like to group some routes not starting with a certain word/segment (like "admin").
To do so I defined in the Config/Routes.php a group like

$routes->group('(?!admin)', function($routes) {

// routes defined here


but this only works out if I change in the system/Router/Router.php the line 419

if (preg_match('#^' . $routeKey . '$#u', $uri, $matches)) {


if (preg_match('#^' . $routeKey . '$#u', '/' . $uri, $matches)) {

Why is that?

I got that workaround from "https://www.phpliveregex.com/" as it turnes out that there are no matches for a certain route without the starting "/":

The pattern "^(?!admin)/index" will find matches against "/index" but not against "index"

PHP Code:

(04-11-2023, 11:24 AM)Mni.day Wrote:
PHP Code:

That's it. Thanks a lot! Couldn't figure that out from the regex docs...

Theme © iAndrew 2016 - Forum software by © MyBB