Guide to data validation in HubSpot with Regex
As of yesterday, all HubSpot accounts are included in the beta testing of a new update where you can now set validation rules for your HubSpot data with Regex (regular expressions).
This is a very powerful new way to validate and ensure quality of your CRM data, but it also comes is a format that is beyond confusing to most, so I will try to demonstrate and simplify how to use this new feature to your advantage.
How and where can you use regex in HubSpot?
The option to use regex validation will be an alternative to using the existing "simple rules", and is at least for now only available in text properties. You can of course use this validation to receive and validate numbers as well, but the property has to be of type "Single-line text", or "Multi-line text"
Why should you validate data input?
There are many reasons to validate different data in different ways even when we have determined the data type to be "text" (or "string" if you are fancy 😉).
In addition to just making sure the data we put into our CRM system is valid, like having an "@" in an email address or the right amount of characters in a postal code, this is also useful to enforce consistency in your data. Including or ignoring things like punctuation in identifying data can later prevent you from finding reliable information, or prevent you from flagging duplicates.
Validation can be especially useful when importing data from files or API, because you can set your own message to explain what is wrong, and how to correct it. When you import spreadsheets to HubSpot, a validation error will also enable you to re-map certain values directly instead of going over each record in the CRM after the fact.
Example:
Say you are storing company registration numbers in your CRM, and you have set this property to require unique values so you don't create duplicates. You already have Hubex in your CRM with the identifier "924 980 729", and you try to add a new company with the registration number "924980729".
By default, these are not the same value, but by enforcing that all values should either include or skip the extra spaces, you will see that this is in fact the same company.
How to write regex rules
When creating or editing a property, go to the "Rules" tab to set up a regex validation rule, and test to confirm that your validation is working as expected.

Regular expressions have a very comprehensive and advanced syntax that can be difficult to understand, and I will not make this article into a course on regex but you can easily spend hours trying to learn how to understand these sequences and what they mean.
If you wish to dive into this, you can check out this cheat sheet from QuickRef as a place to start, but if you just want to get going, copy someone else's expressions, or use tools like Gemini to explain your need, and copy their response. That is a quick and easy way to set the rules you want, even if you have your own rules you need to apply.

Usage examples
Here are some examples of common use cases for regex rules that you can copy to get you started.
A valid email address
This rule will check that your text contains some text before and after an "@" symbol, as well as ends with at least a two-level domain.
Name validation
This rule will check that your text only contains regular letters (A-Z or a-z), spaces, or hyphens (-).
Website validation
This rule will check that your text can start with a protocol (http(s)://) and a subdomain (usually www) and contains at least a brand domain and a top level domain (example.com). It also allows for a URL path and query parameters.