Tool Open source

grex

grex is a command-line tool and Rust library with Python bindings that generates a regular expression from user-provided test cases. It aims to produce the shortest possible expression that matches the supplied strings, using literals, character classes, alternation, optional groups, repeated substrings with quantifiers, prefixes and suffixes, and optional anchors; command-line options or library preprocessing can generalize the result for cases such as digits and repeated values. The CLI accepts strings and can read input from a file. By default, the generated expression is intended to match only the supplied test cases, while options such as shorthand character classes can broaden its matches. It produces Perl-compatible expressions compatible with Rust's regex crate, and the project recommends inspecting generated expressions by hand for domain-specific correctness and engine-specific optimization.

View repository Visit site Mentioned in 1 video ↓

What grex is used for

1 use taken from transcripts — each links to the moment in the video.

  • Generates regular expressions from a list of strings they should match. It can produce more generic expressions through options for digits and repeating values, and can accept input from a file.

Videos mentioning grex

1 in the library.