Documentation Index

Fetch the complete documentation index at: https://docs.unqork.io/llms.txt

Use this file to discover all available pages before exploring further.

Regular Expression Patterns

Prev Next

Several Unqork components support a Regular Expression Pattern (RegEx) field that restricts what end-users can enter. When a pattern is set, the field must match it before the module can be submitted. This guide explains how patterns work and provides common examples ready to use.

What Is a Regular Expression?

A regular expression, commonly called regex, is a sequence of characters that defines a rule for matching text. For example, ^\d{5}$ means exactly five digits and would match 90210 but reject 9021 or 9021A.

Regex patterns in Unqork follow standard JavaScript regex syntax.

How to Use a Pattern

In a supported component, enter the pattern in the Regular Expression Pattern (Regex) field. Use the Pattern Error Message field to provide a clear message when the value does not match, like "Please enter a valid US zip code."

Important: Test patterns before using them in production. The free tool at https://regex101.com lets Creators test a pattern against sample values and explains each part of the expression.

Common Patterns

Numbers

Pattern Matches Example
^\d+$ One or more digits only 12345
^\d{5}$ Exactly five digits 90210
^\d{1,10}$ Between 1 and 10 digits 42
^[0-9]+(\.[0-9]{1,2})?$ Number with up to two decimal places 9.99

Text

Pattern Matches Example
^[a-zA-Z]+$ Letters only, no spaces Smith
^[a-zA-Z\s]+$ Letters and spaces John Smith
^[a-zA-Z0-9]+$ Letters and numbers, no spaces User123
^[a-zA-Z0-9\s\-]+$ Letters, numbers, spaces, and hyphens New York-2

US Formats

Pattern Matches Example
^\d{5}(-\d{4})?$ US zip code (5-digit or ZIP+4) 90210 or 90210-1234
^\d{3}-\d{2}-\d{4}$ Social Security Number 123-45-6789
^\d{3}[.\-]?\d{3}[.\-]?\d{4}$ US phone number 555-867-5309 or 5558675309

Dates

Pattern Matches Example
^\d{4}-\d{2}-\d{2}$ ISO date format 2026-03-25
^\d{2}/\d{2}/\d{4}$ US date format 03/25/2026

Web

Pattern Matches Example
^https?://[^\s]+$ URL beginning with http or https https://example.com

Pattern Syntax Reference

To match a special character, prefix it with \. For example, \. matches a period instead of any character.

Syntax Meaning Example
^ Beginning of input ^Hello matches strings that begin with Hello
$ End of input world$ matches strings that end with world
\d Any digit (0–9) \d\d\d matches three digits
\s Any whitespace character \s matches a space or tab
[abc] Any character in the set [aeiou] matches any vowel
[a-z] Any character in the range [a-z] matches any lowercase letter
[^abc] Any character NOT in the set [^0-9] matches any non-digit
+ One or more of the preceding \d+ matches one or more digits
* Zero or more of the preceding \d* matches zero or more digits
? Zero or one of the preceding \d? matches an optional digit
{n} Exactly n repetitions \d{5} matches exactly five digits
{n,m} Between n and m repetitions \d{3,5} matches three to five digits
. Any character except newline a.b matches axb, a1b, and so on.

Changelog

Date Change
Initial publication.