Regular Expressions 101

Community Patterns

Url parser

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:(?:(?:([^:\/\/]+):)?\/\/)?(?:([\w\-.@]+)(?::(.*))?@)?([\w-.]+)(?::([0-9]+))?)?(?:(\/.*?\/?)(?:([\w-.]+))?)?(?:\?([^#]*))?(?:#(.*))?$
/
gmi

Description

Parse url with any complexity

Submitted by Bohdanov Mikhail - 8 years ago