Regular Expressions 101

Community Patterns

Simple Best URL Regex Match

2

Regular Expression
PCRE (PHP <7.3)

/
^(?P<protocol>[a-z\-]+)?:?(?P<host>\/\/.*\.[^\/]+)$
/
gm

Description

Best URL Regex to match URL, This is simple and can match 64K of url regex under 20ms

Regex Matches All Below and more:

Submitted by anonymous - 3 years ago