Regular Expressions 101

Extract root domain from URL

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
(?:[^:]+:\/\/)(?: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