Formular to extract the domain of a URL

Is there a way to extract the domain from a text field that contains the URL.

Example:
URL: cobas® 8100 automated workflow series
Extracted domain: diagnostics.roche.com

hi @JHConsulting , like below?

thisRow.[the url].totext().slice(1,sum(thisRow.[the url].Find(".com"),Length(".com")))

best, christiaan

2 Likes

Hi @JHConsulting ,
if you want something more generic embracing a wider variety of URLs, perhaps the Regex could be helpful (credit to this: javascript - Regular Expression - Extract subdomain & domain - Stack Overflow)
However, there are some caveats to take into considerations:

  1. You rely on a formula that is not supported (I hope it will, eventually): RegexExtract()
  2. I wasn’t able to extract only the matching group, so it’s a a bit of a double work that I don’t like… Maybe somebody can find the issue.

Anyway, you put on a variable (Regex as a column or named formula) the regex:
^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)

And then:

URL.RegexReplace(Regex, "$1").regexExtract(Regex)

I hope this helps.
Cheers!

3 Likes

Thank you. Works fine with .com

Thank you. I will try it.