Skip to content
Advertisement

Using REGEXP_SUBSTR to extract website domain

I have a field called Website with examples that look like:

I am trying to use REGEXP_SUBSTR to isolate the domain: REGEXP_SUBSTR("Website", '[^https://]+')

Some of the results are working but others are not, for instance I am expecting cornstalk.com and penny.co but I am not receiving those values:

Any help would be appreciated.

Advertisement

Answer

You can use

Details:

  • ^ – start of string
  • (https?://)? – an optional Group 1: http:// or https://
  • (.*) – Group 2: the rest of the string.

The last argument, together with e last but one argument, returns the Group 2 value.

However, REGEXP_REPLACE might be better here:

That is, just remove the http:// or https:// from the start of a string.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement