if
1 year ago

Regex for one of the route parameters to not match an array of strings

Posted 1 year ago by if

Hello,

I'm trying to make a dynamic subdomains routing, when searching on google I've came across this Regex :

    Route::pattern('sub', '^(?!.*(cdn|www)).*$');
    Route::domain('{sub}.domain.com')
         ->middleware('shops')
         ->namespace($this->namespace)
         ->group(base_path('routes/shops.php'));

but unfortunatly it does match also words like 'xcdn' and 'hiwww', do you have any suggestions?

Thank you in advance.

Please sign in or create an account to participate in this conversation.