Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?!graphql|dashboard|telescope)[\/\w-]*
/
gm

Description

When creating a SPA we could capture all routes except some.

Needed this for Laravel

Route::get('/{any?}', function () { return 'Not captured'; })->where('any', '^(?!graphql|dashboard|telescope)[/\w\·-]*');

Submitted by aldo-f - 2 years ago