Regular Expressions 101

Community Patterns

Community Library Entry

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 - 8 years ago (Last modified a year ago)