A regular expression, or regex, is a pattern made up of symbols and characters. Regex is used to match strings with specific patterns, similar to a very powerful text search.
Quickbase offers three regex functions. These functions allow you to parse text so you can extract, replace, or match data in your table.
This article covers the three regex functions available in Quickbase. It does not provide an in-depth explanation of regex.
In this article
Before you start
Quickbase’s implementation of regex is based on the Google RE2 standard. This helps ensure it is performant, stable, and secure. To use the regex functions in Quickbase, you need to be familiar with regex and the Google RE2 standard.
Consider using outside resources, like regex101, or the MDN Regex cheatsheet, to learn more about regex and pattern matching
Regex functions and formula field types
Regex always operates on text. This means that if the input is a non-text field, like a number or phone number, you need to use the ToText() conversion function. It also means the output is a text value. In most cases, this means you’ll use the formula - text field type for regex formula functions. However, if you want to use a different field type, like formula - numeric, make sure to use conversion functions like ToNumber().
Backslashes in regex functions
Escape backslashes used in regex formula functions. For example, if your regex contains \d
, write \\d
.
RegexMatch
Use the RegexMatch formula function to match data in your table. This is useful for validating data, like email addresses and phone numbers.
Function | Formula output | Example formula | Input | Result |
RegexMatch() | Boolean value | RegexMatch([Email Address], "^[\\w\\.+-]+@[\\w\\.-]+\\.\\w+$") | “user@example.com” | TRUE |
invalid_email | FALSE |
RegexExtract
Use the RegexExtract formula function to extract a certain part of a text string that matches the regular expression. If the formula finds no matches, it returns a blank value. This is useful to do things like extract a specific part of a URL.
Only the first match in the text is returned by the formula.
Function | Formula output | Example formula | Input | Result |
RegexExtract() | Alphanumeric characters | RegexExtract([url], "\\b[\\w-]+$") | https://example.com/product/12345 | 12345 |
https://example.com/no-product-here | Blank | |||
RegexExtract([email], "@(.*)") | Joe.smith@aol.com | aol.com | ||
RegexExtract("test string is this","t*") | test string is this |
te Note: te is the first match, and the only one returned. tr and th are not returned because they come after te. |
RegexReplace
Use the RegexReplace formula function to substitute values that match the regular expression with a replacement value. This is useful for things like normalizing phone numbers.
Function | Formula field type | Example formula | Input | Result |
RegexReplace() | Formula - text | RegexReplace(ToText([client_contact]), "[()-. ]", "") | (555) 123-4567 | 5551234567 |
555.555.5555 | 5555555555 |
Troubleshoot regex strings
We suggest testing regular expressions using online resources like regex101. Select Golang under Flavor. There may be small differences in syntax.