Skip to content

Commit e0a286d

Browse files
committed
docs: escape regex
1 parent 2e8d926 commit e0a286d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/docs/guide/essentials/route-matching-syntax.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ Now, going to `/25` will match `/:orderId` while going to anything else will mat
4141
Make sure to **escape backslashes (`\`)** like we did with `\d` (becomes `\\d`) to actually pass the backslash character in a string in JavaScript.
4242
:::
4343

44+
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):
45+
46+
```js
47+
const routes = [
48+
// note the escaped closing parentheses of the group within the regexp
49+
{ path: '/:custom(somethnig-(nested|other\\))' },
50+
]
51+
```
52+
4453
## Repeatable params
4554

4655
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):

0 commit comments

Comments
 (0)