Regular Expressions 101

Community Patterns

Parse Entire URL

1

Regular Expression
PCRE (PHP <7.3)

/
https?:\/\/(?:www\.)?([-a-zA-Z0-9@:%._\+~#=]{2,256})(\.[a-z]{2,6}\b)*(\/[\/\d\w\.-]*)*(?:[\?])*(.+)*
/
gi

Description

This regex is a mashup that strips protocol, domain and URI into seperate capture groups.

Submitted by Robert Kozora - 8 years ago