Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Extract Domain, Subdomain and TLD from URL by script

Hi,

in the load script i want to add some new fields. I load a field "URL" and want to exctract the domain, subdomain and TLD from each URL by script.

Example:

URL: https://help.qlik.com/de-DE/sense/3.1/Subsystems/Hub/Content/Scripting/DateAndTimeFunctions/month.ht...

Domain: qlik.com

SubDomain: help.qlik.com

TLD: com

Somebody know´s the expression?

regards,

sam

2 Replies
Anonymous
Not applicable
Author

I create an expression to extract the Subdomain:

Load

mid("URL", index("URL", '://')+3, index("URL", '/',3)-index("URL", '://')-3) as Subdomain

...

Domain and TLD is difficult, because if i check the extracted Subdomain i could search for Points, but the problem is, that some TLD´s have a Point like "co.uk"

Example - extract the TLD:

help.qlik.co.uk

qlik.co.uk

help.qlik.com

qlik.com


Do you know a solution?


Regards,

sam

Anonymous
Not applicable
Author

Here is an update for the SubDomain expression:

// Wenn das es ein 3. Vorkommen von / gibt, dann lese die Domain bis zum 3 / aus

if(index(varTestURL6, '/',3)>0,mid(varTestURL6, index(varTestURL6, '://')+3, index(varTestURL6, '/',3)-index(varTestURL6, '://')-3),

// Ansonsten prüfe, ob ? und # nicht vorkommen, wenn ja, dann bis ans Ende auslesen

if(index(varTestURL6, '?',1)=0 AND index(varTestURL6, '#',1)=0, 'einfach bis ans ende',

  // Ansonsten prüfe, ob ? und # vorkommen

  if(index(varTestURL6, '?',1)>0 AND index(varTestURL6, '#',1)>0,

    // Wenn ja, dann prüfe, ob ? vor # vorkommt, wenn ja, dann bis ? auslesen, ansonsten bis #

    if(index(varTestURL6, '?',1)<index(varTestURL6, '#',1),'bis ?','bis #'),

        // Wenn nicht (kann entweder nur ? oder # vorkommen), dann prüfe, ob ? vorkommt, wenn ja, dann bis ? lesen, ansonsten bis #

    if(index(varTestURL6, '?',1)>0,'bis ?','bis #')

)))

regards,

sam