Webflags: g
OpenAPI Path Template
Match OpenAPI / Express-style path templates with `{param}` (or `:param` after substitution) placeholders.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\/[\w\-]+(?:\/(?:\{[\w\-]+\}|[\w\-]+))*\/? (flags: g)Raw source: \/[\w\-]+(?:\/(?:\{[\w\-]+\}|[\w\-]+))*\/?
How it works
\/[\w\-]+ matches the first path segment. The repeating group (?:\/(?:\{[\w\-]+\}|[\w\-]+))* matches subsequent segments — either literal text or a `{param}` placeholder. \/? allows an optional trailing slash. Useful for path-to-handler routing tables.
Examples
Input
GET /users/{id}/posts/{postId}/commentsMatches
/users/{id}/posts/{postId}/comments
Input
/api/v1/healthMatches
/api/v1/health
Input
no pathNo match
—Common use cases
- •OpenAPI spec validation
- •Express / Next.js dynamic-route extraction
- •Path-template comparison (match similar routes)
- •Auto-generating client SDKs from path templates