Regular Expressions 101

Community Patterns

1...34567...901

Community Library Entry

13

Regular Expression
PCRE (PHP <7.3)

/
(((ftp|http|https):\/\/)|(\/)|(..\/))(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?
/

Description

Validates -

  1. URLs with schemes - http, https and ftp

  2. Relative URL starting with / and ../

Submitted by anonymous - 10 years ago