Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(^|\s)((https?:\/\/)?[\w-]+(\.[a-z-]+)+\.?(:\d+)?(\/\S*)?)
/
gim

Description

Finds:

  • links with or without http/s
  • links with or without www
  • short links
Submitted by PonyOny - 9 years ago