Skip to main content
Solved

How to remove everything after a root domain URL

  • July 29, 2021
  • 2 replies
  • 44 views

Hi all, I’m trying to create a formula that helps me trim a product specific link to its root website link.

For example, I have: https://freestar.co/products/12-x-bottles
And want to get: https://freestar.co

In some cases, the links are https://www. and sometimes they are are above (without the www).

Could you help me out?

Best answer by kuovonne

Welcome to the Airtable community,

This is a great use case for regular expressions.
If all of your urls will begin with “https”, you could use this formula

IF(
  REGEX_MATCH({url}, "https://[^/]+"),
  REGEX_EXTRACT({url}, "https://[^/]+")
)

2 replies

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • Answer
  • July 29, 2021

Welcome to the Airtable community,

This is a great use case for regular expressions.
If all of your urls will begin with “https”, you could use this formula

IF(
  REGEX_MATCH({url}, "https://[^/]+"),
  REGEX_EXTRACT({url}, "https://[^/]+")
)

Welcome to the Airtable community,

This is a great use case for regular expressions.
If all of your urls will begin with “https”, you could use this formula

IF(
  REGEX_MATCH({url}, "https://[^/]+"),
  REGEX_EXTRACT({url}, "https://[^/]+")
)

Thank you @kuovonne - this worked perfectly! :clap: