Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\b(?:https?:\/\/)?(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(?:\.[a-z]{2,})?\/?
/
gm

Description

Domains with alphanumeric characters ranging from 3 to 9 in length, followed by a top-level domain (TLD) that is 2 to 3 characters long. Also, it accounts for the possibility of second-level domains such as .co.uk.

Submitted by anonymous - a year ago (Last modified a year ago)