Skip to main content

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. You can also export unit tests as code or export their results.

Free
Included
Pro
Included
Self-hosted
Included
Compare plans

Generate code for the target language​

  1. Enter a pattern and test strings, or open the order example.
  2. Select Code Generator in the left panel, under Tools.
  3. Select a Language in the toolbar above the preview, or search by name.
  4. Select Copy code or Download code on the right of the toolbar.
  5. Follow the setup and run instructions at the top of the example.

The generator includes the pattern, flags, and all enabled test strings in a runnable example. It preserves input names and editor order. Disable a test string to exclude it.

Code generator settings opens Settings > Editor > Conversion & output. The Code generator language setting selects a default for both regex examples and unit-test code. Automatic chooses a language from the editor's selected flavor.

Choose a language, then copy or download the generated code.
Code Generator with the language selector open above the runnable example.

This JavaScript example extracts 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']

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.

  1. Open Export Matches after the pattern produces results.
  2. Choose JSON, JSON Lines, CSV, or Plain Text in Export format.
  3. Open Export options beside the format selector.
  4. Select the match fields and metadata required by the receiving program.
  5. Inspect the preview.
  6. Select Copy all matches or Download all matches in the toolbar above the preview.

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. Both actions export the complete result for the selected options. Downloads use the selected format: .json, .jsonl, .csv, or .txt.

Choose the format and fields for your exported matches.
Match export in CSV format with the export field options open.

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.