Regular Expressions 101

Community Patterns

Get dynamic parameters from an URL

2

Regular Expression
PCRE (PHP <7.3)

/
(?:http\:\/\/(?:www\.)?){1}[^\/]*\/([^\/]*)(?#parameter2)(?:\/([^\/]*))?(?#parameter3)(?:\/([^\/]*))?(?#parameter4)(?:\/([^\/]*))?
/

Description

Gets the parameters (how many you want) from a url and organize into groups

Submitted by Caio Oliveira - 10 years ago