Regular Expressions 101

Community Patterns

Community Library Entry

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 - 9 years ago