Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
^(?:http|ftp)s?:\/\/([\w][^\/=\s]+)\/?|(^w{3}[\.\w][^\/\=\s]{2,})\/?
/
mg

Description

extracts hostname from url

Submitted by Kristine Poghosyan - 9 years ago