Regular Expressions 101

Community Patterns

HTTP url parser

2

Regular Expression
PCRE (PHP <7.3)

/
((http[s]?\:)\/\/)?([^\?\:\/#]+)(\:([0-9]+))?(\/[^\?\#]*)?(\?([^#]*))?(#.*)?
/
i

Description

Parses a URL to the different parts

Submitted by AmitK - 10 years ago