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
Related patterns
URL Path Segment
WebMatch individual `/segment` parts of a URL path, capturing each one.
Cookie Header Value
WebParse name=value pairs from an HTTP `Cookie:` header value.
CSS Class from `class=""` Attribute
WebExtract the value of a `class="..."` attribute from raw HTML, handling double or single quotes.
CSS Custom Property (Variable)
WebMatch CSS custom properties (variables) like `--brand-color` or `--font-size-lg`.