Extract values from matches
When the pattern matches, Extraction builds output from those matches and discards unmatched input. The extraction template controls both the values and their separators.
- Free
- Included
- Pro
- Included
- Self-hosted
- Included
Extract order numbers
- Select JavaScript and Extraction mode.
- Enable
g. - Enter this pattern:
\bORD-([0-9]{4})\b
- Paste this input:
ORD-0042 pending
ORD-0187 sent
ORD-42 invalid
XORD-0001 invalid
- Enter
$1\nin the extraction template.
The output contains each captured number followed by a newline:
0042
0187
There is also a newline after 0187. In JavaScript extraction output, \n inserts a line break.
Regular substitution uses Order $1. Extraction uses $1\n and returns one identifier per line.
Choose a separator
The editor concatenates the template output for each match. It does not add a separator automatically.
| Extraction template | Exact output |
|---|---|
$1 | 00420187 |
$1, | 0042,0187, |
$1\n | 0042\n0187\n |
The comma example includes a final comma. For a downstream format that forbids it, remove that final separator after extraction.
Compare the operations
For the same pattern and replacement Order $1, ordinary substitution preserves the status words and line break.
Extraction returns Order 0042Order 0187 because it keeps only the template output.
If the output contains only one value, verify that g is active.
If a capture reference appears literally, verify its syntax for the selected engine.
Refine an extraction with AI Assistant
Ask AI Assistant for the values and separators you want, using representative input examples. Review its regex and extraction template, then apply each change you want. See Review and apply suggestions for local checks and Undo.
Handle zero matches
With no matches, Extraction returns an empty string. For no orders here, the match count is 0 and the output is empty.
Wait for processing to finish before copying the output.
To verify the setup, restore the positive order example. The match count is 2, and the output contains 0042 and 0187 on separate lines.