LinuxCommandLibrary

grex

Regex generator from example strings

TLDR

Generate regex from examples

$ grex [foo] [bar] [baz]
copy
Case insensitive matching
$ grex -i [example1] [example2]
copy
Allow digits
$ grex -d [test1] [test2]
copy
Escape special characters
$ grex -e [example]
copy
Output with anchors
$ grex --with-anchors [examples...]
copy

SYNOPSIS

grex [options] test-strings

DESCRIPTION

grex generates regular expressions from user-provided test strings. It analyzes the input examples and produces a regex that matches all of them.
The tool supports various character class conversions and can detect patterns like repetitions. It is useful for quickly creating regexes without manual pattern analysis.

PARAMETERS

TEST-STRINGS

Example strings to generate regex from.
-d, --digit
Convert digits to \d.
-s, --space
Convert spaces to \s.
-w, --word
Convert alphanumerics to \w.
-i, --ignore-case
Case insensitive matching.
-e, --escape
Escape all non-ASCII chars.
--with-anchors
Add start/end anchors.
-r, --repetition
Detect repetitions.
--help
Display help information.

CAVEATS

Generated regex may be overly specific or general. Manual refinement often needed. Complex patterns may require additional examples.

HISTORY

grex was created by Peter M. Stahl as a command-line tool to simplify regex creation through example-based learning.

SEE ALSO

grep(1), sed(1), regex(7)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community