Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(?<scheme>\w+):\/\/((?<user>\w+)(\:(?<password>[^\/:]+))?@)?(?<hostname>[\w-.]+)(:(?<port>\d+))?\/(?<request>(?<path>[^#\s\?]+)(\?(?<query>[^#\s]+))?(#(?<fragment>[^#\s]+))?)?
/
g

Description

Matches any forms of common URLs with a single regular expression

Submitted by np.trivial - 8 years ago