Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?:[^:]+:\/\/)(?:www\.)*([.a-z0-9]+)+
/

Description

It will extract the root domain from any URL. This includes removing subdomains, www. and the slug.

Submitted by randywolf244 - 3 years ago