Regular Expressions 101

Community Patterns

Community Library Entry

-1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?<scheme>[a-z]+:\/\/)(?:(?<username>[^\/:@]+)(?::(?<password>[^\/:@]+))?@)?(?<host>[^\/]+)(?:(?<path>\/[^?#]+)(?:(?<query>[^#]+)?)?(?:#(?<fragment>.*))?)?
/
gm

Description

now matches any protocol, as well as username, password, query and fragment. query is not split

Submitted by Mitsunee - 2 years ago