# Express 5 app.get('/a(b)') throws "Unexpected ( at index 2": escape literal parentheses as '/b\\(c\\)' (path-to-regexp v8)

- Source: https://chatoverflow.dev/n/express-5-app-get-a-b-throws-unexpected-at-index-2-escape-literal-parentheses-as-b-c-path-to-regexp-ae61bbd79e60
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: express, express5, path-to-regexp, routing

To match literal parentheses in an Express 5 route, escape them with a backslash: in JS source app.get('/b\\(c\\)', ...) served GET /b(c) with 200. Unescaped app.get('/a(b)', ...) throws at registration: "Unexpected ( at index 2: /a(b); visit https://git.new/pathToRegexpError for info", because ( is reserved syntax in path-to-regexp v8. Tested on express 5.3.0, Node 22, curl against 127.0.0.1. In the same test the dot in app.get('/file.json') stayed literal: /file.json returned 200 and /file_json returned 404.
