Skip to content

Match a Pattern in Smart Redact: A Simple Guide to Regex

Match a Pattern in Smart Redact: A Simple Guide to Regex

What is a pattern?

A pattern describes the shape of a text, not the exact text. Use a pattern when the values you want to find follow the same format but are different each time.

For example, loan numbers such as LN-0012345 and LN-0098765 are different values with the same shape: the letters LN, a hyphen, and seven digits. You do not need to add each number as a custom term. One pattern finds them all: LN-\d{7}
Patterns are also known as regular expressions, or regex. You do not need to be a developer to write one. Most patterns use only a few simple building blocks, shown below.

How patterns work in Smart Redact

  • Type the pattern only. Do not add slashes or flags. Type \d{6}, not /\d{6}/g

  • Upper and lower case are treated the same. LN-\d{7} finds LN-0012345 and ln-0012345

  • Patterns match whole words. \d{6} finds 123456, but not six digits inside a longer number such as 1234567

  • The pattern is checked as you type. A pattern with an error, or a pattern that could match empty text, cannot be added

  • The live count shows the result before you save. For Always Detect, it shows how many matches the pattern finds. For Never Detect, it shows how many suggestions it would hide

  • Limits: 100 characters per pattern and 100 characters per pattern name

Note: Never Detect always wins. To stop an Always Detect pattern from finding one specific value, add that value to Never Detect. To learn how the two lists work together, see What takes priority.

Building blocks

These are the most used symbols. Combine them with normal text to describe the shape you want to find.

Symbol What it means Example Finds
\d Any digit, 0 to 9 \d\d 42
[A-Z] Any letter [A-Z]\d B7
[A-Z0-9] Any letter or digit [A-Z0-9]{4} X9K2
{4} Exactly 4 of the item before it \d{4} 2026
{2,5} Between 2 and 5 of the item before it \d{2,5} 12, 123, 12345
+ One or more of the item before it ID\d+ ID7, ID12345
? The item before it is optional \d{3}-?\d{3} 123-456, 123456
| Or Account|Acct Account, Acct
( ) Groups items together Ref\s\d{5} Ref 12345
. Any single character A.C ABC, A1C, A-C
\ Placed before a symbol, it makes the symbol plain text No\. \d{3} No. 123

 

Build a pattern step by step

Start from a real value in your document, then describe it part by part.

Example value: CASE-2026-00417

Part of the value Is it always the same? What to type
CASE- Yes CASE-
2026 No, it is always four digits \d{4}
- Yes -
00417 No, it is always five digits \d{5}

Final pattern: CASE-\d{4}-\d{5}
Type the parts that never change as normal text. Replace the parts that change with a building block.

Ready-to-use patterns

Copy a pattern and change the text and the numbers to fit your documents.

Goal Pattern Finds

A fixed-length number

\d{10}

0012345678

A number with a prefix

LN-\d{6,10}

LN-123456, LN-0012345678

A reference code

[A-Z]{2}\d{4}-\d{2}

AB1234-56

Several exact words

Acme Corporation|Acme Corp

Acme Corporation, Acme Corp

A case number

Case No\. \d{2}-\d{5}

Case No. 26-00417

An invoice number

INV-\d{4,8}

INV-2045, INV-00982045

An employee ID

EMP\d{5}

EMP04521

A policy number with a letter

POL-[A-Z]\d{7}

POL-K1234567

A number with or without hyphens

\d{3}-?\d{3}-?\d{3}

123-456-789, 123456789

A date written with slashes

\d{2}/\d{2}/\d{4}

03/15/2026

The same label written in two ways

(Account|Acct) \d{8}

Account 12345678, Acct 12345678

 

Common mistakes

Mistake What happens How to fix it

The pattern is too broad, for example \d+

It matches every number in the document

Add the fixed text or the exact length, for example LN-\d{7}. Check the live count before you save

Slashes or flags are added, for example /\d{6}/g

The pattern does not find what you expect

Type the pattern only: \d{6}

A dot is typed as plain text, for example No. 123

The dot matches any character, so the pattern can find more than you want

Put a backslash before it: No\. 123

The pattern describes only part of a word or number

Nothing is found, because patterns match whole words

Describe the full value, from its first character to its last

The pattern can match empty text, for example \d*

The pattern cannot be added

Use + or an exact length, for example \d+ or \d{6}

 

Tip: These symbols have a special meaning in a pattern: . + ? | ( ) [ ] { } \. To find one of them as plain text, put a backslash before it.

Learn more

For more information about custom terms, categories, and how to import and export your settings as a JSON file, see Customize Smart Redact: Custom Terms, Categories, and Settings.

 

 

Last updated: November 18, 2026