Regular Expressions 101

Regex to match URLs in a string

Open Workspace
  • JavaScript
  • Match
1

Regular Expression

/
(http|https)\:\/\/[a-zA-Z0-9.-]+(\.[a-zA-Z]+)+(\/.*)?
/
gm

Description

Regex to match URLs in a string with http and https protocol and optional paths in URL

Submitted by Kaustubh