Regular Expression Validation
Regular expression (regex) validation lets admins set their own format rules on Text fields. Claravine checks every value against your rule and flags anything that doesn't fit, so naming conventions, ID formats, and clean URLs are enforced the moment data is entered.
Note: Regular expression validation is available on Claravine Management. If you don't see the option in the Rules section of a Text field, contact your Claravine account manager.
In this article
- What is a regular expression?
- Ways to use regex validation
- How validation works in Claravine
- Add regex validation to a Text field
- Test your regex pattern
- Regex basics
- Commonly requested regex patterns
- Limitations and alternatives
What is a regular expression?
A regular expression (regex) is a short text rule, written as a string of characters, that describes what a valid value looks like. For example, [A-Z]{3}-\d{6} means "three capital letters, a dash, then six digits." A value like ABC-123456 passes. A value like ab-12 fails.
You don't need to be a developer to use regex. Most Claravine rules come from a handful of building blocks, and you can start from one of the commonly requested regex patterns below.
Ways to use regex validation
| Goal | What regex does | Example |
|---|---|---|
| Enforce a naming convention | Turns a written naming guide into a rule users can't skip. | Lowercase with underscores, proper case, camel case |
| Standardize IDs and codes | Requires a specific structure and length. | Three capitals, a dash, six digits |
| Keep URLs clean | Blocks malformed links before they reach your analytics. | No trailing slash, no doubled ?? or &&
|
| Protect downstream systems | Stops hidden characters and line breaks at the source. | No line breaks loading into your data warehouse |
How validation works in Claravine
- It checks, it doesn't change. A value either matches your regex pattern or the cell shows an error. Claravine does not reformat the value.
-
The whole value must match.
[a-z]+rejectsabc1because the digit isn't covered by the regex pattern. -
Rules describe what's allowed. To block a character, write a regex pattern that allows everything else. For example,
[^?&]*blocks?and&. - Each rule checks one cell. A regex pattern can't compare a value to another field.
When validation runs
| Where | What users see |
|---|---|
| In the grid, as users enter data | Your custom error message (or the default) on the cell. Submission is blocked until the value is fixed. |
| At submission: file import, inbound sync, and API | Always the default message: "This value doesn't meet the required format." |
Validation runs on every path, so your standards hold no matter how data arrives.
Add regex validation to a Text field
You can add regex validation to a Text field in a field set, or to a pattern variable segment in the template editor.
- Open the field set or template that contains the Text field.
- In the field's Rules section, check Regular expression validation. It appears below Custom exclusion.
- Enter your regex pattern (up to 200 characters).
- Enter a custom error message (up to 150 characters). This is optional but strongly recommended, because it tells users exactly what format to use. Leave it blank and users see "This value doesn't meet the required format."
- Click Test with a few sample values. See Test your regex pattern.
- Save your changes.
Screenshot to add: Regular expression validation checkbox, regex pattern field, and custom error message in the Rules section of a Text field.
Reuse a saved regex pattern
After you save a field set, a + icon appears next to the regex pattern field. Click it to see regex patterns already saved on the same field set, plus the template's own fields when you're editing a template. The most recent regex patterns show first, with no duplicates. Select one to reuse it.
Note: The list only includes regex patterns from the same field set or template. A regex pattern drops off the list once no field uses it.
Remove regex validation
Uncheck Regular expression validation. This deletes the regex pattern and its error message. You can't pause a regex pattern, so copy it somewhere safe first if you may want it again.
Test your regex pattern
Test before you save so you don't block valid data.
- Enter a sample value in the test field below your regex pattern.
- Click Test. A Valid or Invalid badge shows the result.
- Try several samples, including values that should pass and values that should fail.
Important: Claravine doesn't check your regex pattern as you type. Click Test to see the result, and fix any syntax errors, such as an unclosed bracket, before saving.
Regex basics
These building blocks cover most Claravine rules. Combine them to describe almost any format.
| Syntax | Meaning | Example regex pattern | Matches | Fails |
|---|---|---|---|---|
abc |
Literal characters | FY26 |
FY26 | fy26 |
[abc] |
Any one listed character | [ABC] |
B | D |
[a-z] |
A range of characters | [a-z0-9]+ |
spring26 | Spring26 |
[^abc] |
Any character not listed | [^ ]+ |
no_spaces | has space |
\d \w \s |
Digit, word character, whitespace | \d{4} |
2026 | 26 |
. |
Any single character | Q. |
Q3 | Q |
* + ? |
Zero or more, one or more, optional | v\d+ |
v12 | v |
{n} {n,m} |
Exact or ranged count | [A-Z]{2,3} |
US | U |
(a|b) |
Either option | (US|CA|MX) |
CA | UK |
^ $ |
Start and end of the value | ^FY\d{2}$ |
FY26 | FY2026 |
\. \- \\ |
Escape a special character | www\.\w+\.com |
www.claravine.com | wwwXclaravineXcom |
Tip: Put a backslash before any character with a special meaning: . ? + * ( ) [ ] { } \ |. Use \\ for a literal backslash.
Tip: Regex patterns are case-sensitive. To allow both cases, list both, such as [Aa] or [a-zA-Z].
Commonly requested regex patterns
Copy a regex pattern, adjust it to your conventions, and test it with a few sample values before you save.
| Goal | Regex pattern | Passes | Fails |
|---|---|---|---|
| Proper case | ^[A-Z][a-z]*(?:\s[A-Z][a-z]*)*$ |
Your Name | your NAME |
| Camel case required | ^[a-z][a-z0-9]*(?:[A-Z]?[A-Z][a-z0-9]+)*[A-Z]?$ |
thisIsATest | this is a test |
| Camel case blocked | ^(?:[^a-z].*|[^A-Z]*)$ |
this is a test | thisIsATest |
| Lowercase with underscores | ^[a-z0-9]+(?:_[a-z0-9]+)*$ |
summer_sale_26 | Summer_sale |
| Uppercase allowed only for X and O | ^[^A-NP-WYZ]*$ |
XsamoOplex | XSAMOOPLEX |
| ID: three capitals, a dash, six digits | ^[A-Z]{3}-\d{6}$ |
ABC-123456 | AB-123456 |
| Fixed list of values | ^(US|CA|MX)$ |
CA | UK |
| Valid email address | ^[A-Za-z0-9_%+-]+(?:\.[A-Za-z0-9_%+-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z]{2,}$ |
abc@gmail.com | abc.gmail.com |
| No trailing slash on URLs | ^.*[^/ ]$ |
www.claravine.com | www.claravine.com/ |
| Block ? and & | ^[^?&]*$ |
summer_sale | summer?sale |
| No repeated ? or & in a URL (such as ??? or &&) | ^(?:\?(?:&\?)*&?|&(?:\?&)*\??)?(?:[^?&]+(?:\?(?:&\?)*&?|&(?:\?&)*\??))*[^?&]*$ |
a?b=1&c=2 | a???b |
| Exclude cmp= and ? | ^(?:[^c?]|c(?:c|mc|mpc)*(?:[^cm?]|m[^cp?]|mp[^c=?]))*(?:c(?:c|mc|mpc)*(?:mp?)?)?$ |
www.claravine.com | cmp=www.claravine.com? |
| No line breaks | ^[^\r\n]*$ |
summer sale | A value with a line break |
| No non-breaking spaces | ^[^\x{00A0}]*$ |
abc | A value with a non-breaking space |
| No hidden characters | ^[^\x{00}-\x{1F}\x{7F}\x{00A0}\x{200B}-\x{200D}\x{2060}\x{FEFF}]*$ |
summer_sale | A value with a zero-width space |
Limitations and alternatives
| Not supported | Example | What to do instead |
|---|---|---|
| Case-insensitive mode | (?i)abc |
List both cases: [Aa][Bb][Cc] or [a-zA-Z]
|
| Lookahead and lookbehind |
(?=x), (?<=x)
|
Rewrite as a plain regex pattern, or split the rule across fields. |
| Large counted repetition | \w{1,5000} |
Keep counts small. Claravine rejects regex patterns that expand past its limit. |
| Regex patterns over 200 characters | Long lists of allowed values | Use a pick list field instead. |
| "Must not match" rules | Reject any value containing ? | Write a regex pattern that allows everything else, such as [^?]*
|
| Rules across fields | If Field A is X, Field B must be Y | A regex pattern checks one cell only. For complex cases, split and extract on a field with a regular expression. |
| Invalid syntax | [a-z |
Close all brackets and groups, then click Test before saving. |
Note: Claravine blocks regex patterns that could slow down processing. It checks at save time and again when data is validated, and rejects regex patterns it considers unsafe.
Updated
Comments
0 comments
Please sign in to leave a comment.