Regular Expressions 101

URL-Matcher

1

Regular Expression
PCRE (PHP <7.3)

/
(?<!=\")\b((?:http|https|ftp):\/\/)((?:(?:\w)+\.)+(?:\w)+)(:\d+)?((?:\/[\w]+)*[.\w]*\/?)((?:[\?\w\=\_\-%+!$^*\/\\@#;:]|(?:&(?!gt;)|(?:['"](?=[\w"'&#,]))))*)
/
g

Description

a simple url regex which prevents matching of a trailing ">" (the html representation of a closeing angle bracket ">")

Submitted by Erich Spaker - 9 years ago