Regular Expressions 101

Community Patterns

Simple URL Regex

1

Regular Expression
PCRE (PHP <7.3)

/
((https?:\/\/|(ftp:\/\/)).*|(.*\.[^\.]{2,6})(\/.*)?)(\:.*)?$
/
gm

Description

Regex for http/https/ftp or only domain url

Examples: https://example.domain/page?=78 http://example.domain/page?=78 ftp://192.168.0.1:80 example.domain example.domain:80/test

Submitted by Adrien H - 8 years ago