Info: This article is work in progress and subject to change.
This appendix is a working reference for the regular-expression syntax used in the Configurator’s two regex slots: Keep pattern (which characters can be typed) and Pattern (which final values are valid).
For the conceptual material on how the two slots differ, see 02d — How conditions work and 06c — Requiring values and validating input.
The Configurator uses standard JavaScript regular expressions. Anything that works in modern JavaScript regex works here.
The two slots, side by side
| Slot | Behaviour | Common usage |
|---|---|---|
| Keep pattern | Filters input as the user types. Anything that does not match is dropped silently | Constrain the input alphabet — only digits, only letters, only uppercase |
| Pattern | Validates the final value. Shows the Pattern message if the value does not match | Shape-check the result — exact length, prefix, format |
Use them together: a Keep pattern to make typing safer, a Pattern to validate the shape of the result.
Character classes
A character class describes a set of characters. The user can type any character in the class.
| Class | Matches |
|---|---|
[a-z] |
Lowercase letters |
[A-Z] |
Uppercase letters |
[A-Za-z] |
Any letter |
[0-9] |
Digits |
[a-zA-Z0-9] |
Letters and digits |
[A-Za-z ] |
Letters and spaces |
[A-Za-z0-9_-] |
Letters, digits, underscore, and dash |
[^0-9] |
Anything except digits (the ^ at the start of the class negates) |
Predefined character classes
| Class | Matches |
|---|---|
\d |
A digit (equivalent to [0-9]) |
\D |
A non-digit |
\w |
A word character (letter, digit, or underscore) |
\W |
A non-word character |
\s |
Whitespace (space, tab, newline) |
\S |
Non-whitespace |
. |
Any single character |
Note: Use the explicit forms ([0-9], [A-Za-z]) in Keep patterns rather than \d or \w. The explicit forms are clearer to readers reviewing your panel configuration later.
Quantifiers
Quantifiers say how many times the preceding character or group must repeat. Used most often in Pattern, not Keep pattern.
| Quantifier | Meaning |
|---|---|
? |
Zero or one |
* |
Zero or more |
+ |
One or more |
{3} |
Exactly three |
{3,5} |
Three to five |
{3,} |
Three or more |
Examples:
| Pattern | Reads as |
|---|---|
[A-Z]{3} |
Exactly three uppercase letters |
[0-9]{1,3} |
One to three digits |
[A-Za-z]+ |
One or more letters |
Anchors
Anchors say where in the value the match should occur. Used in Pattern to ensure the entire value matches:
| Anchor | Meaning |
|---|---|
^ |
Start of value |
$ |
End of value |
Most Patterns implicitly anchor to the whole value, but explicitly anchoring with ^…$ is the safest approach:
| Pattern | Reads as |
|---|---|
^[A-Z]{3}[0-9]{4}$ |
Exactly three uppercase letters followed by four digits, with nothing else |
Tip: When a Pattern is “almost working” but lets through extra characters, missing anchors are usually the cause. Add ^ at the start and $ at the end and re-test.
Common Keep-pattern recipes
| Keep pattern | What the user can type |
|---|---|
[0-9] |
Digits only |
[A-Z] |
Uppercase letters only |
[A-Za-z] |
Letters only |
[A-Za-z ] |
Letters and spaces |
[A-Za-z0-9 ] |
Alphanumerics and spaces |
[A-Za-z0-9_-] |
Letters, digits, underscore, dash (good for technical identifiers) |
[\d.] |
Digits and decimal points |
Keep patterns are what is allowed, not the shape of the value. They run on every character the user types. Use them for the input alphabet, not for length or structure.
Common Pattern recipes
| Pattern | Valid value |
|---|---|
^[0-9]{13}$ |
Exactly 13 digits |
^[A-Z]{3}[0-9]{4}$ |
Three uppercase letters followed by four digits |
^[0-9]+\.[0-9]{2}$ |
A price with exactly two decimal places |
^[A-Za-z]{3,50}( [A-Za-z]{3,50})*$ |
One to many words, each 3-50 letters |
^https?://.+$ |
A URL starting with http:// or https://
|
^\+?[0-9]{8,15}$ |
A phone number with optional +, 8 to 15 digits |
^[A-Z0-9]{5,12}$ |
An identifier of 5-12 uppercase letters or digits |
Always pair a Pattern with a Pattern message
A regex match failure with no message gives the user a generic error. A Pattern message turns the error into a useful one:
| Pattern | Pattern message |
|---|---|
^[0-9]{13}$ |
ISBN must be exactly 13 digits. |
^[A-Z]{3}[0-9]{4}$ |
Project code must be three uppercase letters followed by four digits, e.g. PRJ1234. |
^https?://.+$ |
URL must start with http:// or https://. |
^\+?[0-9]{8,15}$ |
Phone number must contain 8-15 digits, optionally starting with +. |
The pattern is <what is wrong> — <what shape it should take, with an example>.
Common pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| No anchors on a Pattern | The Pattern matches a substring instead of the whole value | Add ^ and $
|
| Keep pattern is too narrow | The user cannot type characters they need | Widen the class. Test the Keep pattern with realistic input |
| Pattern mismatch silent | No Pattern message set | Always set the Pattern message |
| Forgetting to escape special characters | Pattern parses but matches nothing | Escape ., (, ), [, ], +, *, ?, \, | with a leading backslash when matching them literally |
| Greedy quantifier in a long Pattern | Slow validation, occasional infinite loops | Avoid .* followed by .*; use specific character classes |
Test patterns in a regex tester first
The fastest way to verify a Pattern is in a live regex tester (regex101.com and similar). Type your Pattern, type sample valid values, type sample invalid values, and confirm each matches as expected. Once it does, paste it into the Configurator.
Tip: Always test at least one valid value, one invalid value, and one edge-case value (empty string, very long string, leading and trailing whitespace). The edge cases reveal Pattern mistakes that simple positive examples miss.
Cross-references
- 02d — How conditions work — regex primer
- 05a — Fields reference — every Field’s Keep pattern and Pattern options
- 06c — Requiring values and validating input — practical patterns and pattern messages
Revisions
- 8 May 2026: First publication of the manual
Comments
0 comments
Please sign in to leave a comment.