Tips, Tricks & Best Practices

helenechoo
Participante

Regex for Contact has viewed at least one URL that matches regular expression

resolver

Hi,

 

I'm trying to create a regex that matches:

 

https://www.youweagency.com/staffing

youweagency.com/staffing

youweagency.nl/staffing

youweagency.se/staffing

https://www.youweagency.com/e-commerce

youweagency.nl/e-commerce

 

where staffing or e-commerce can also be hosting or strategy-organization etc. (we have 8 of those in total),

 

but does not match:

 

https://www.youweagency.com/e-commerce/e-commerce-and-pim-one-integrated-suite

youweagency.nl/e-commerce/e-commerce-and-pim-one-integrated-suite

 

so anything after e-commerce (or any of the other 7) shouldn't match.

 

I've been trying this:

 

https\:\/\/(www\.|\.)youweagency\.(com|nl|se)\/(e\-commerce|staffing|hosting|strategy\-organization|experience\-design|data\-intelligence|digital\-marketing|content\-management)$

 

which I tested with https://www.regextester.com/ and worked fine.

 

I can't get it to work here in Hubspot though.

 

Could you please help?

 

Thanks in advance!

0 Avaliação positiva
1 Solução aceita
John
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro Platinum

Regex for Contact has viewed at least one URL that matches regular expression

resolver

You need to make the https:// and www. strings optional

 

 

(?:https?\:\/\/)?(www\.)?youweagency\.(com|nl|se)\/(e\-commerce|staffing|hosting|strategy\-organization|experience\-design|data\-intelligence|digital\-marketing|content\-management)$

 

 

The ? makes anything preceeding it optional. Please note, I did not test this in hubspot.

 

Edit: if you want to account for query strings and tracking codes, then you could remove the $ at the end of the regex above and add the following code to the end: (?:\?.*)?



I like kudos almost as much as cake – a close second.

Exibir solução no post original

7 Respostas 7
natsumimori
Gerente da Comunidade
Gerente da Comunidade

Regex for Contact has viewed at least one URL that matches regular expression

resolver

Thank you @tjoyce for tagging in @John !


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!

John
Solução
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro Platinum

Regex for Contact has viewed at least one URL that matches regular expression

resolver

You need to make the https:// and www. strings optional

 

 

(?:https?\:\/\/)?(www\.)?youweagency\.(com|nl|se)\/(e\-commerce|staffing|hosting|strategy\-organization|experience\-design|data\-intelligence|digital\-marketing|content\-management)$

 

 

The ? makes anything preceeding it optional. Please note, I did not test this in hubspot.

 

Edit: if you want to account for query strings and tracking codes, then you could remove the $ at the end of the regex above and add the following code to the end: (?:\?.*)?



I like kudos almost as much as cake – a close second.

helenechoo
Participante

Regex for Contact has viewed at least one URL that matches regular expression

resolver

That worked, thanks!

0 Avaliação positiva
John
Orientador(a) | Parceiro Platinum
Orientador(a) | Parceiro Platinum

Regex for Contact has viewed at least one URL that matches regular expression

resolver

Thanks @tjoyce. @helenechoo, here are some questions for you to answer before any of us can help: Is this a text field, url field, or link field? Are you developing locally or in the hs IDE?



I like kudos almost as much as cake – a close second.

helenechoo
Participante

Regex for Contact has viewed at least one URL that matches regular expression

resolver

Hi @John,

Thanks for reacting!

 

This is in the contact property Hubspot score:

Screenshot 2020-11-10 at 15.21.47.png

Sorry, not a developer so not sure whether this answers your question!

Let me know if you need any more information.

 

Best,

Helene

0 Avaliação positiva
tjoyce
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

Regex for Contact has viewed at least one URL that matches regular expression

resolver

I am going to tag @John - I have seen him write some beautiful regex's and hopefully he has an answer for you @helenechoo 

natsumimori
Gerente da Comunidade
Gerente da Comunidade

Regex for Contact has viewed at least one URL that matches regular expression

resolver

Hi @helenechoo ,

 

Thanks for reaching out to the HubSpot Community. I'm not too familiar with this topic, but let's see if Community member can share some thoughs!

@tjoyce , is this topic something you can share advice? 


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!