Regular Expressions 101

Community Patterns

URL infos

1

Regular Expression
PCRE (PHP <7.3)

/
(?<Address>(?<Protocol>https?:\/\/)?(?<Subdomain>\w*\.)?(?<Domain>(?:[a-z0-9\-]{2,})\.(?:[^\s\/\.]{2,}))(?<Path>\/[^\s\?]*)?(?<Params>(?:\?|\#)[^\s\/\?\:]*)?)
/
gi

Description

A powerful regex (fewest steps possible) which gives you all the information about urls.

Submitted by MCMainiac - 9 years ago