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

**URL:** <https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612>\
**Category:** Questions\
**Tags:** regular-expressions, functions\
**Created:** [February 26, 2025, 8:25pm UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612 "2025-02-26T20:25:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LukeAnthonyHoughton](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@LukeAnthonyHoughton](https://community.make.com/u/LukeAnthonyHoughton)\
**Post date:** [February 26, 2025, 8:25pm UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612/1 "2025-02-26T20:25:51Z")

</div>

How can I remove the following from a URL:  
• http://  
• https://  
• [http://www](http://www).  
• [https://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](https://www.google.com/contant) then I want [google.com](http://google.com) to remain for the field value.

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 27, 2025, 4:15am UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612/2 "2025-02-27T04:15:34Z")

</div>

Welcome to the Make community!

You can use the built-in function `replace`

e.g.:

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

```

**Proof:** [https://regex101.com/r/5PvbEu/1](https://regex101.com/r/5PvbEu/1)

[![Screenshot_2025-02-28_080241](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/4/d/4d79a34cb808251430a2b397ef4878a582ecc0ee.png)](https://regex101.com/r/5PvbEu/1)

For more information, see the `replace` function documentation in the [Help Center](https://www.make.com/en/help) and do the [tutorials in the Make Academy](https://academy.make.com).

> The search pattern is a [regular expression](https://en.wikipedia.org/wiki/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.
> 
> - The complete list of metacharacters can be found on the [MDN web docs website](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
> - For a tutorial on how to create regular expressions, we recommend the [RegexOne website](https://regexone.com/).
> - For an easy, quick regex generator, try the [Regular Expressions generator](https://regex-generator.olafneumann.org/).
> - For experimenting with regular expressions, we recommend the [regular expressions 101 website](https://regex101.com/). Just make sure to tick the ECMAScript (JavaScript) FLAVOR in the left panel.

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

— @samliew

P.S.: Investing some effort into the [Make Academy](https://academy.make.com) will save you lots of time and frustration using Make.

---

<div class="post-metadata">

**Author:** ![LukeAnthonyHoughton](https://avatars.discourse-cdn.com/v4/letter/l/d6d6ee/32.png) [@LukeAnthonyHoughton](https://community.make.com/u/LukeAnthonyHoughton)\
**Post date:** [February 27, 2025, 12:41pm UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612/3 "2025-02-27T12:41:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 28, 2025, 12:24am UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612/4 "2025-02-28T00:24:27Z")

</div>

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](https://community.make.com/t/make-community-the-ultimate-topic/11682) 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](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/5/d/5d9b26fbef0fd7385a34084f61cd5b9165786f42.png)

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](https://academy.make.com) will save you lots of time and frustration using Make.

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [March 13, 2025, 12:46pm UTC](https://community.make.com/t/trim-anything-before-and-after-url-domain-and-extensions-domain-extension/71612/5 "2025-03-13T12:46:44Z")

</div>


