Regular Expressions 101

Community Patterns

Detecting urls in a block of text

1

Regular Expression
PCRE (PHP <7.3)

/
\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]
/
ig

Description

no description available

Submitted by http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/ - 8 years ago