Regular Expressions 101

Url regex that capture the domain of the URLs

Open Workspace
  • JavaScript
  • Match
1

Regular Expression

/
(?:http|https):\/\/((?:[\w-]+)(?:\.[\w-]+)+)(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?
/
gm

Description

https://developer.mozilla.org/es/docs/Web/JavaScript https://www.google.es/webhp?hl=es

Matches:

MATCH 1

  1. developer.mozilla.org

MATCH 2

  1. www.google.es
Submitted by D<OS>