Regular Expressions 101

Url regex that capture the domain of the URLs

1

Regular Expression
ECMAScript (JavaScript)

/
(?: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> - 8 years ago