Regular Expressions 101

Community Patterns

Match any url in text or html (http, https)

3

Regular Expression
PCRE2 (PHP >=7.3)

/
(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)
/
gm

Description

Match any url in text or html (http, https)

Submitted by Jérémy Munsch - 2 years ago