From e0a286d86406dc4308d2e513f0d9e6d3b733a1b3 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 22 Sep 2025 11:19:20 +0200 Subject: [PATCH] docs: escape regex --- packages/docs/guide/essentials/route-matching-syntax.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/docs/guide/essentials/route-matching-syntax.md b/packages/docs/guide/essentials/route-matching-syntax.md index b1824498..e1455840 100644 --- a/packages/docs/guide/essentials/route-matching-syntax.md +++ b/packages/docs/guide/essentials/route-matching-syntax.md @@ -41,6 +41,15 @@ Now, going to `/25` will match `/:orderId` while going to anything else will mat Make sure to **escape backslashes (`\`)** like we did with `\d` (becomes `\\d`) to actually pass the backslash character in a string in JavaScript. ::: +Since the closing parentheses `)` is used to mark the end of a custom regex, you must escape it inside of the regexp (e.g. nested groups): + +```js +const routes = [ + // note the escaped closing parentheses of the group within the regexp + { path: '/:custom(somethnig-(nested|other\\))' }, +] +``` + ## Repeatable params If you need to match routes with multiple sections like `/first/second/third`, you should mark a param as repeatable with `*` (0 or more) and `+` (1 or more): -- 2.47.3