GR
SOFTWARE

grex

grex 1.4.6 is a command-line tool that generates readable regular expressions from positive examples, generalizing numbers, whitespace, words and repeated fragments into more reusable matching rules.

Version v1.4.6Windows x64Apache-2.0

Example-driven pattern generation

grex constructs a candidate regular expression from a set of sample strings. It can generalize digits, whitespace, words and repeated fragments, which is useful for log identifiers, filenames and structured labels. It is a pattern assistant rather than a complete business-data validator.

Why counterexamples matter

The tool sees positive samples but does not know what must be rejected. Too few examples can make an expression memorize existing values, while aggressive generalization can accept values outside the intended range. Keep positive, negative and boundary cases in a versioned test set.

Engine compatibility

The project targets PCRE-compatible and Rust regular-expression syntax, while JavaScript, Java, .NET, editors and other engines differ in escaping, Unicode, anchors and advanced features. Validate the final expression in the environment that will execute it, and assess performance against untrusted input.

Review date: 2026-08-06.

SAVE TO CLOUD

Save to your cloud drive

Open the cloud drive to get the file directly, or save it for convenient access on another device.

Links checked 2026-08-06
Save first, access when you need itOn desktop, scan with the matching cloud-drive app. On mobile, tap the save button.
GUIDE

grex Windows regular-expression generation guide

Generate a conservative expression from several non-sensitive positive examples, add counterexamples and boundary cases, and broaden digit, whitespace or word matching only after the target engine passes the full test set.

Before you start

  • Prepare at least three structurally similar positive examples with different values and several strings that must be rejected.
  • Identify the final engine, such as JavaScript, .NET, Java, PCRE or Rust, and record its escaping and feature differences.
  • Use fictional samples rather than accounts, tokens, phone numbers or other sensitive values that would enter terminal history.
01

Installation steps

  1. 01

    Extract the Windows tool

    Extract the archive to a fixed tools directory, confirm the grex executable and preserve its version so scripts can reproduce the same candidate expression.

  2. 02

    Verify the command

    In PowerShell, display help through the full path; add the directory to the user PATH only when a stable workflow has been tested.

  3. 03

    Create a test corpus

    Store fictional positive and negative samples in an independent text file or test script and write down the expected match result for each case.

02

Quick start

  1. 01

    Generate the default expression

    Pass several positive examples to grex, keep the default anchors and specific characters first, and map each generated fragment back to the samples.

  2. 02

    Test positives and negatives

    Put the output into the target program or a regex test, confirm every positive matches and every negative is rejected, then add empty, long and boundary inputs.

  3. 03

    Broaden the pattern carefully

    Enable digit, whitespace, word or repetition generalization only when the requirement calls for it, and rerun the complete corpus after each change.

Usage tips

  • The default result is usually more conservative than a highly generalized expression; prove correctness before optimizing for short syntax.
  • Versioned unit tests with positive and negative samples reveal regressions more reliably than storing the final pattern alone.
  • For untrusted input, evaluate the target engine's execution cost and avoid expressions that can consume excessive time.
Troubleshooting and uninstall

Why does the result match only the original samples?

The default expression can be deliberately specific. Add representative samples, then generalize only the numeric, whitespace or word fragments that are truly variable.

Why does the pattern work in grex but fail in application code?

Inspect string escaping, delimiters, Unicode and anchor semantics in the target language. Compare the raw expression with the exact string passed to the engine.

  1. Remove the executable and PATH entryConfirm that scripts and automation no longer call the directory, remove its user PATH entry and delete the extracted files; retain the test corpus with the project when useful.
FAQ

Frequently asked questions

Does grex guarantee that the generated expression matches only the intended data?

No. It aims to cover the positive examples, but missing counterexamples and business constraints are not inferred. Add explicit rejection and boundary samples and test in the final engine.

Which regular-expression engines are supported?

The project targets PCRE-compatible and Rust syntax. JavaScript, Java, .NET and editor engines have different escaping and feature sets, so validate the final expression where it will run.

Do I still need to understand regular expressions?

Yes. Review anchors, character classes, groups and repetition ranges before deployment so the generated candidate fits the actual rule instead of being too broad or too narrow.