Regular Expressions 101

Community Patterns

Basic matching of HTTP/HTTPS URLs

0

Regular Expression
PCRE (PHP <7.3)

/
^https?:\/\/(.*:.*@)?[^\.:]+(\.[^\.:]+){1,2}(\:\d+)?[^:]+$
/
gm

Description

Basic enforcing of URL minimal structure, without being too strict.

Supports:

user:pass@ domain.com:80

Bugs:

I worked it out quickly; can't guarantee it works in all cases. Please test with wider range of cases, and report bugs if you find them.

Submitted by anonymous - 5 years ago