Regular Expressions 101

Extract domain from URL

Open Workspace
  • JavaScript
  • Match
1

Regular Expression

/
^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)
/
igm

Description

Extract the domain out of an url

Submitted by anubhava