Copy code or export matches
Use the code generator to transfer a pattern into an application. Use match export to copy the current results as data.
- Free
- Included
- Pro
- Included
- Self-hosted
- Included
Generate code for the target language
- Enter a pattern and test string, or open the order example.
- Select Code Generator in the left panel, under Tools.
- Open Language in the dialog header (1). Select a language, or type its name in Search languages….
- Select Copy code (2).
The generator inserts the pattern, flags, and test string into a snippet for the selected language. Changing this selector changes the generated code; it does not change the editor's regex engine.
Code generator settings opens Settings > Editor > Code generation & formatting. The Code generator language setting selects a default. Automatic chooses a language from the editor's selected flavor.
The following JavaScript also verifies the two captured identifiers:
const input = 'ORD-0042 pending\nORD-0187 sent\nORD-42 invalid\nXORD-0001 invalid'
const pattern = /\bORD-(?<id>[0-9]{4})\b/g
const identifiers = [...input.matchAll(pattern)].map((match) => match.groups.id)
console.log(identifiers)
// ['0042', '0187']
This example extracts the named captures directly. Generated snippets also include a loop for inspecting each match and capture.
Export the current matches
Export Matches is available under Tools and in the Match Information header. Both buttons are disabled while matches are processed or when there are no matches.
- Open Export Matches after the pattern produces results.
- Choose JSON, JSON Lines, CSV, or Plain Text in Export format.
- Open Export options beside the format selector.
- Select the match fields and metadata required by the receiving program.
- Inspect the preview.
- Select Copy all matches.
Structured formats can include match number, group name, group number, position, and match text. The Non-Participating Groups control includes groups that did not capture a value. Plain text disables the structured metadata controls.
The preview can truncate a large result. The copy action exports the complete result for the selected options. With no matches, there is no result to export.
Choose extraction or export
Extraction is useful when you want a custom line or separator for each match. Match export is useful when the receiving tool expects structured fields.
Verify quoting and encoding in the receiving application, particularly for CSV values containing commas, quotes, or newlines. For differences in positions or matching, compare the target runtime.