Nov 9, 2020 10:33 AM
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!
Solved! Go to Solution.
Nov 10, 2020 11:28 AM - edited Nov 10, 2020 11:31 AM
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.
Nov 11, 2020 2:10 AM
Nov 10, 2020 11:28 AM - edited Nov 10, 2020 11:31 AM
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.
Nov 11, 2020 1:44 AM
That worked, thanks!
Nov 10, 2020 9:18 AM
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.
Nov 10, 2020 9:23 AM
Hi @John,
Thanks for reacting!
This is in the contact property Hubspot score:
Sorry, not a developer so not sure whether this answers your question!
Let me know if you need any more information.
Best,
Helene
Nov 10, 2020 4:17 AM
I am going to tag @John - I have seen him write some beautiful regex's and hopefully he has an answer for you @helenechoo
Nov 9, 2020 9:44 PM
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?