Regular Expressions 101

Community Patterns

Regex to fetch domain name from url

0

Regular Expression
PCRE (PHP <7.3)

/
^(?:http(?:s?):\/\/(?:www\.)?)?([A-Za-z0-9_:.-]+)\/?
/
gm

Description

The 3rd group of the match will give the domain name

Submitted by anonymous - 5 years ago