From: Eduardo San Martin Morote Date: Mon, 22 Sep 2025 09:19:20 +0000 (+0200) Subject: docs: escape regex X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e0a286d86406dc4308d2e513f0d9e6d3b733a1b3;p=thirdparty%2Fvuejs%2Frouter.git docs: escape regex --- 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):