You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The path argument is used to define parameters and populate the list of keys.
52
+
The path argument is used to define parameters and populate keys.
53
53
54
54
#### Named Parameters
55
55
56
-
Named parameters are defined by prefixing a colon to the parameter name (`:foo`). By default, the parameter will match until the next prefix (e.g. `[^/]+`).
56
+
Named parameters are defined by prefixing a colon to the parameter name (`:foo`).
57
57
58
58
```js
59
59
constregexp=pathToRegexp("/:foo/:bar");
@@ -65,7 +65,61 @@ regexp.exec("/test/route");
65
65
66
66
**Please note:** Parameter names must use "word characters" (`[A-Za-z0-9_]`).
67
67
68
-
#### Parameter Modifiers
68
+
##### Custom Matching Parameters
69
+
70
+
Parameters can have a custom regexp, which overrides the default match (`[^/]+`). For example, you can match digits or names in a path:
It is possible to write an unnamed parameter that only consists of a regexp. It works the same the named parameter, except it will be numerically indexed:
It is possible to write an unnamed parameter that only consists of a matching group. It works the same as a named parameter, except it will be numerically indexed.
0 commit comments