Useful Regex Patterns for HubSpot Search and Replace
Regex — regular expressions — can feel intimidating if you haven't used them before. But for HubSpot data cleanup, you don't need to be a regex expert. A handful of practical patterns cover the vast majority of real-world scenarios: standardizing phone numbers, fixing URLs, cleaning up email addresses, and normalizing text formatting.
This guide provides copy-paste regex patterns for common HubSpot search-and-replace operations. Each pattern is explained in plain language so you understand what it matches and why, not just how to use it.
Here's a regex pattern in action — stripping HTML tags from contact notes:
Quick regex primer
If you're new to regex, here are the building blocks used in the patterns below:
| Symbol | Meaning | Example |
|---|---|---|
. | Any single character | a.c matches "abc", "a1c", "a-c" |
* | Zero or more of the previous | ab*c matches "ac", "abc", "abbc" |
+ | One or more of the previous | ab+c matches "abc", "abbc" but not "ac" |
? | Zero or one of the previous | colou?r matches "color" and "colour" |
\d | Any digit (0-9) | \d\d\d matches "123", "456" |
\s | Any whitespace | hello\sworld matches "hello world" |
\b | Word boundary | \bcat\b matches "cat" but not "category" |
[...] | Any character in the set | [aeiou] matches any vowel |
(...) | Capture group | Used to reference matched text in replacements |
\1 | Back-reference to group 1 | Used in the search pattern to match the same text again |
^ | Start of string | ^Hello matches "Hello world" |
$ | End of string | world$ matches "Hello world" |
In replacement strings, captured groups are referenced as $1, $2, etc.
Phone number patterns
Standardize US phone numbers to (XXX) XXX-XXXX
Many HubSpot portals have phone numbers in a dozen different formats. This pattern matches most common US phone number formats and lets you standardize them.
Search pattern:
\+?1?[\s.-]?\(?(\d{3})\)?[\s.-]?(\d{3})[\s.-]?(\d{4})
Replacement:
($1) $2-$3
What it matches:
5551234567555-123-4567(555) 123-4567555.123.45671-555-123-4567+1 555 123 4567+15551234567
What it produces: (555) 123-4567 in every case.
Add country code to US phone numbers
If you need to standardize to international format:
Search pattern:
\+?1?[\s.-]?\(?(\d{3})\)?[\s.-]?(\d{3})[\s.-]?(\d{4})
Replacement:
+1$1$2$3
Result: +15551234567
URL patterns
Replace HTTP with HTTPS
If your CMS content or CRM records contain links using http://, you can upgrade them to https://:
Search pattern:
http://
Replacement:
https://
This is a simple literal replacement — no regex needed. But if you want to be precise and avoid double-converting already-HTTPS URLs (in case a property contains the literal text "http://https://"), you can use:
Search pattern:
(?<!s)http://
Replacement:
https://
The (?<!s) is a negative lookbehind that prevents matching if "http" is preceded by "s" (i.e., it won't match inside "https://").
Update a domain across all content
When a company you link to changes domains:
Search pattern:
oldpartner\.com
Replacement:
newpartner.io
Note the escaped dot (\.). In regex, a bare . matches any character, so oldpartner.com would also match oldpartnerXcom. Escaping the dot ensures you only match the literal period.
Fix trailing slashes
Standardize URLs to not have trailing slashes (or to always have them):
Search pattern (remove trailing slashes):
(https?://[^\s"']+[^/\s"'])/+(\s|$|[)"'])
Replacement:
$1$2
This is a more advanced pattern. In practice, if you just need to fix a specific set of URLs, literal replacements are simpler and safer.
Email domain patterns
Fix common email domain typos
Users frequently mistype popular email domains. These patterns catch the most common ones:
Gmail typos:
| Search | Replace |
|---|---|
@gmial\.com | @gmail.com |
@gmal\.com | @gmail.com |
@gamil\.com | @gmail.com |
@gmail\.co$ | @gmail.com |
@gnail\.com | @gmail.com |
Other common typos:
| Search | Replace |
|---|---|
@yaho\.com | @yahoo.com |
@yahooo\.com | @yahoo.com |
@hotmal\.com | @hotmail.com |
@outloo\.com | @outlook.com |
Run each of these as a separate search-and-replace operation. Preview the results before applying — you don't want to "fix" a legitimate domain that happens to look like a typo.
Find personal email addresses
To identify contacts using personal email providers (useful for filtering B2B records):
Search pattern:
@(gmail|yahoo|hotmail|outlook|aol|icloud|mail|protonmail|zoho)\.(com|co\.uk|de|fr)$
This pattern is useful for searching and identifying records, even if you don't want to replace the values — use it to find contacts, then manually decide what to do with them.
Text cleanup patterns
Remove extra whitespace
Clean up fields with double spaces, leading spaces, or trailing spaces:
Search pattern (double spaces):
+
Replacement:
(That's two-or-more spaces replaced with a single space.)
Search pattern (leading whitespace):
^\s+
Replacement: (empty string)
Search pattern (trailing whitespace):
\s+$
Replacement: (empty string)
Fix smart quotes and special characters
Data imported from Word documents or rich text editors often contains smart quotes and em dashes that display as garbage characters in some systems:
| Search | Replace |
|---|---|
\u2018 or \u2019 | ' |
\u201C or \u201D | " |
\u2013 | - |
\u2014 | -- |
Note: Whether Unicode escape sequences work depends on your tool's regex engine. You may need to paste the actual characters instead.
Standardize capitalization artifacts
If data was imported in ALL CAPS and you want to flag those records:
Search pattern:
^[A-Z\s]{10,}$
This matches values that are entirely uppercase letters and spaces, at least 10 characters long. It's useful for identifying records that need capitalization cleanup, though the actual case conversion usually requires a script or spreadsheet formula.
Company name patterns
Standardize company suffixes
Search (find inconsistent suffixes):
| Search | Replace |
|---|---|
\bInc$ | Inc. |
\bIncorporated$ | Inc. |
\bLLC$ | LLC |
\bL\.L\.C\.$ | LLC |
\bLtd$ | Ltd. |
\bLimited$ | Ltd. |
The \b word boundary prevents matching "Included" when searching for "Inc," and the $ anchors the match to the end of the string so you're only matching suffixes, not text in the middle of a company name.
Remove "The" prefix
Some companies are entered as "The Acme Corporation" while others are just "Acme Corporation":
Search pattern:
^The\s+
Replacement: (empty string)
Preview carefully — "The New York Times" should probably keep its "The."
Country and state standardization
US country value standardization
Run these in order, from most specific to least:
| Search | Replace |
|---|---|
^United States of America$ | United States |
^U\.S\.A\.$ | United States |
^USA$ | United States |
^U\.S\.$ | United States |
^US$ | United States |
Using ^ and $ anchors ensures you're matching the entire field value, not a substring. Without anchors, searching for "US" would match "Australia" and "Russia."
Tips for safe regex in HubSpot
-
Always preview first. Regex can match more than you expect. Review every match before applying changes.
-
Start specific, then broaden. Begin with a narrow pattern that matches known cases. Only widen the pattern if you find additional variations.
-
Use anchors when matching entire values.
^US$is much safer thanUSalone. -
Test on a small dataset. If your tool allows it, test the pattern on a filtered set of records before running it across your entire database.
-
Keep a log. Document each pattern you run, what it matched, and how many records were affected. This helps you audit changes and builds a library of patterns you can reuse.
Regex is a powerful tool, but it's also an unforgiving one. A misplaced character can match thousands of unintended records. The combination of regex power with a preview-before-commit workflow is what makes it practical for CRM data cleanup rather than terrifying.
Keep working through the cleanup
Related HubSpot guides for planning, previewing, and validating the next step.
HubSpot Regex Find and Replace: Complete Guide
Learn how to use regular expressions for powerful find-and-replace operations in HubSpot. From basic patterns to advanced techniques for CRM and CMS data.
Read guideHow to Bulk Edit Associations in HubSpot
HubSpot's association system links contacts to companies, deals to contacts, and more. Here's how to manage, fix, and bulk-update these associations when they break or need changing.
Read guideHow to Bulk Edit Date Properties in HubSpot
Date properties in HubSpot have specific format requirements and timezone handling that make bulk editing tricky. Here's how to update dates across many records without breaking things.
Read guideHow to Bulk Edit Multi-Select Properties in HubSpot
Multi-select properties in HubSpot are notoriously difficult to edit in bulk. Here's how they work under the hood and the best approaches for updating them across many records.
Read guideStill editing HubSpot records one by one?
Start with 100 free applied records — no credit card required.