APIs & Integrations

alivia
Contributor

Using regex to match on domain but exclude subdomains

Hello,

 

I'm trying to use regex to build a List based on pageviews and it's driving me a little bit crazy.

 

The goal is to create a list of people that have visited a page on our main website but not on any subdomains.

 

So it would return:

- website.com > yes

- website.com/help > yes

- help.website.com > no

- help.website.com/help > no

 

Can someone please help me out? The documentation on regular expressions is reaaaaally slim..

0 Upvotes
3 Replies 3
Willson
HubSpot Employee
HubSpot Employee

Using regex to match on domain but exclude subdomains

Hey @alivia 

 

I'm not sure which resources you've been working with but have you viewed the following:

  1. Contact List API Docs
  2. Forum example 1
  3. Forum example 2

 

I hope these help!

Product Manager @ HubSpot
0 Upvotes
alivia
Contributor

Using regex to match on domain but exclude subdomains

Hello,

 

Yes I had an intensive session of searching through all existing documentation and was unfortunately unable to get an answer 🙂

 

Alivia

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Using regex to match on domain but exclude subdomains

Hey @alivia 


Do you have any details on what you've attempted so far? Taking a look into it from my end, when I test using Regex101.com I am able to use the following:

Regular expression:
^website.com$

Test String:
website.com
help.website.com

In the above, example, we will only match the 1st string as we're stating that the string should start with website and end with .com, so if any result shows help. etc, this will be excluded. 

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes