Regular Expressions 101

Community Patterns

Community Library Entry

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 - 9 years ago