AFI AFI

Matches regex

Estimated reading: 2 minutes Updated August 1, 2026

Matches regex passes when the field matches the regular expression you supply. Use it for structured values whose shape matters more than their exact content.

When to use it

Choose it when the rule you want cannot be written as a whole-value match or a substring test. Postcode formats, order references, phone number shapes, and domain patterns all suit a regular expression.

For anything simpler, prefer Contains or Starts with. They are faster to read six months later.

How to configure it

  1. Open AFI → Integrations and edit your integration.
  2. Switch on Conditional Logic.
  3. Pick the field, choose Matches regex, and enter your pattern.

Delimiters are optional

Write ^INV-d{6}$ and the pattern works. AFI wraps an undelimited pattern in ~ before running it.

Supply your own delimiters when you need flags. /^inv-d{6}$/i runs case-insensitively. Recognised delimiter characters are /, #, ~, %, @, and |.

Examples

Goal Pattern
UK postcode ^[A-Z]{1,2}d[A-Zd]?s?d[A-Z]{2}$
Invoice reference ^INV-d{6}$
Any company email domain `@(acme acme-group).com$`
Digits only ^d+$

An invalid pattern fails safely

A pattern the engine cannot compile produces no match. The integration is held rather than run with a broken rule. Test your pattern before relying on it, then confirm with a real submission in AFI → Log.

Related