Regular Expressions 101

Community Patterns

URL

1

Regular Expression
PCRE (PHP <7.3)

/
(?P<Protocol>http[s]?:\/\/)?(?P<Host>(?:www.)?\w+.(?P<Domain>\w{1,10}))(?P<Query>.+)
/
gm

Description

separate all parts of an url

Submitted by Kai - 8 years ago