Regular Expressions 101

Community Patterns

All Url links

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