Webflags: g
URL Path Segment
Match individual `/segment` parts of a URL path, capturing each one.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\/([^\/?#\s]+) (flags: g)Raw source: \/([^\/?#\s]+)
How it works
\/ matches the literal slash. ([^\/?#\s]+) captures one or more characters that aren't a slash, question mark, hash, or whitespace — i.e. one path segment. Useful for breaking apart a URL into its component pieces.
Examples
Input
/users/42/posts?page=2Matches
/users/42/posts
Input
/api/v1/healthMatches
/api/v1/health
Input
no/pathNo match
—Common use cases
- •Routing-table introspection
- •URL normalization / rewriting
- •Analytics: per-path-segment aggregation
- •API gateway pattern matching