Trim anything before and after URL domain and extensions (domain.extension)

How can I remove the following from a URL:
• http://
• https://
http://www.
https://www.
• www.
• Remove anything after the extension. For example, domain.extension/contact (google . com / contact).

Lets say that we have https://www.google.com/contant then I want google.com to remain for the field value.

Welcome to the Make community!

You can use the built-in function replace

e.g.:

{{ replace(lower(1.url); "/(^(?:https?:\/\/)?(?:www\.)?|\/.+$)/g"; emptystring) }}

Proof: https://regex101.com/r/5PvbEu/1

Screenshot_2025-02-28_080241

For more information, see the replace function documentation in the Help Center and do the tutorials in the Make Academy.

The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

4 Likes

Wow @samliew thank you so very much. This is absolutely awesome and well explained. I also highly appreciate the link that also explained in greater depth. Simply wonderful, thank you.

1 Like

No problem, really glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

1 Like