Regular Expressions 101

Community Patterns

123...6

URL parser

2

Regular Expression
PCRE2 (PHP >=7.3)

/
^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$
/

Description

The best way to parse URL via Regex. This can be used in javascript, PHP, etc.

Submitted by Ivijan-Stefan Stipic - 7 years ago (Last modified a year ago)