Regular Expressions 101

Extract domain from url

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
(?:http[s]*\:\/\/)*(?<dstdomain>\w*[\-]*\w*\.[a-zA-Z]*)(?:$|\:.*|\/.*)
/
gm

Description

From native squid logs, I retrieve url with http* or not. I use the regex to extract the top domain from the url and store it into a variable

Submitted by Anonymous