RGX(1)

NAME

rgxregex101 for the terminal — real-time matching, 3 engines, capture groups, replace mode, syntax highlighting,…

SYNOPSIS

$brew install brevity1swos/tap/rgx

INFO

180 stars
2 forks
0 views

DESCRIPTION

regex101 for the terminal — real-time matching, 3 engines, capture groups, replace mode, syntax highlighting, plain-English explanations, undo/redo, mouse support. Written in Rust.

README

rgx

A terminal regex tester with real-time matching and multi-engine support

CI Crates.io Downloads License

Test and debug regular expressions without leaving your terminal. Written in Rust.

demo

Press F1 in the app for a multi-page cheat sheet with keyboard shortcuts, regex syntax, and engine-specific features.


Who is this for?

rgx is useful if you:

  • Work on remote servers where opening a browser isn't practical — SSH sessions, containers, air-gapped environments
  • Want to pipe regex results into other commands (echo "log" | rgx -p '\d+' | sort) — regex101 can't do this
  • Need to test against specific engine behavior — check if your pattern works in Rust's regex crate vs PCRE2 without guessing
  • Prefer staying in the terminal and find the context switch to a browser tab disruptive

If you write regex a few times a month and regex101.com works fine for you, it probably still will. rgx is strongest for developers who do regex-heavy work in terminal-centric workflows.

Features

  • Real-time matching — matches update on every keystroke
  • Syntax-highlighted pattern input — AST-based coloring for groups, quantifiers, character classes, anchors, and escapes
  • 3 regex engines — Rust regex (default), fancy-regex (lookaround/backrefs), PCRE2 (full features)
  • Capture group highlighting — distinct colors per group, nested group support
  • Plain-English explanations — walks the regex AST to generate human-readable breakdowns
  • Replace/substitution mode — live preview with $1, ${name}, $0/$& syntax
  • Match detail + clipboard — navigate matches/captures with Up/Down, copy with Ctrl+Y
  • Pattern history + undo — Ctrl+Z/Ctrl+Shift+Z undo/redo, Alt+Up/Down browse history
  • Context-sensitive cheat sheet — F1 multi-page help: shortcuts, regex syntax, engine-specific features
  • Whitespace visualization — toggle with Ctrl+W to show spaces as ·, newlines as , tabs as
  • Mouse support — click to focus/position cursor, scroll to navigate panels
  • Engine selector — switch engines with Ctrl+E, see where behavior differs
  • Regex flags — toggle case-insensitive, multiline, dotall, unicode, extended
  • Stdin pipe supportecho "test string" | rgx '\d+'
  • Non-interactive batch modergx -p -t "input" 'pattern' prints matches to stdout and exits
  • Pipeline composability — pipe in, filter, pipe out: cat log | rgx -p '\d+' | sort -n
  • Vim mode — optional modal editing (--vim or vim_mode = true) with Normal/Insert modes, h/j/k/l navigation, w/b/e word motions, dd/cc/x editing, and all global shortcuts preserved
  • Recipe library — built-in common patterns (email, URL, IP, semver, etc.) — Ctrl+R to browse and load
  • Cross-platform — Linux, macOS, Windows

Installation

From crates.io

cargo install rgx-cli

From prebuilt binaries

Download from GitHub Releases.

Shell installer

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/brevity1swos/rgx/releases/latest/download/rgx-installer.sh | sh

Homebrew

brew install brevity1swos/tap/rgx
More installation methods

From source

git clone https://github.com/brevity1swos/rgx.git
cd rgx
cargo install --path .

Without PCRE2 (zero C dependencies)

cargo install rgx-cli --no-default-features

Usage

# Interactive mode
rgx

Vim mode (modal editing)

rgx --vim

Start with a pattern

rgx '\d{3}-\d{3}-\d{4}'

Pipe text from stdin

echo "Call 555-123-4567 or 555-987-6543" | rgx '\d{3}-\d{3}-\d{4}'

Use a specific engine

rgx --engine fancy '\w+(?=@)'

With flags

rgx -i 'hello'

With replacement template

rgx -r '$2/$1' '(\w+)@(\w+)'

Non-interactive batch mode (--print / -p)

rgx -p -t "hello 42 world 99" '\d+' # prints: 42\n99 echo "log line 404" | rgx -p '\d+' # prints: 404

Count matches only (--count / -c)

echo "a1 b2 c3" | rgx -p -c '\d+' # prints: 3

Extract a specific capture group (--group / -g)

echo "user@host" | rgx -p -g 1 '(\w+)@(\w+)' # prints: user

Batch replacement

rgx -p -t "user@host" -r '$2=$1' '(\w+)@(\w+)' # prints: host=user

Pipeline composability

cat server.log | rgx -p 'ERROR: (.*)' | sort | uniq -c

Capture final pattern after interactive editing

PATTERN=$(rgx -P)

Exit codes: 0 = match found, 1 = no match, 2 = error

rgx -p -t "test" '\d+' || echo "no digits found"

Keyboard Shortcuts

KeyAction
TabCycle focus: pattern / test / replace / matches / explanation
Up/DownScroll panel / move cursor / select match
EnterInsert newline (test string)
Ctrl+ECycle regex engine
Ctrl+ZUndo
Ctrl+Shift+ZRedo
Ctrl+YCopy selected match to clipboard
Ctrl+ROpen regex recipe library
Ctrl+WToggle whitespace visualization
Ctrl+OOutput results to stdout and quit
Ctrl+SSave workspace
Ctrl+Left/RightMove cursor by word
Alt+Up/DownBrowse pattern history
Alt+i/m/s/u/xToggle flags (case, multiline, dotall, unicode, extended)
F1Show help (Left/Right to page through)
Mouse clickFocus panel and position cursor
Mouse scrollScroll panel under cursor
EscQuit (or Normal mode in vim)

Vim Mode (--vim)

KeyModeAction
i / a / I / ANormalEnter Insert mode (at cursor / after / line start / line end)
o / ONormalOpen line below / above and enter Insert mode
EscInsertReturn to Normal mode
h / j / k / lNormalLeft / down / up / right
w / b / eNormalWord forward / backward / end
0 / $ / ^NormalLine start / end / first non-blank
gg / GNormalFirst line / last line
xNormalDelete character under cursor
ddNormalDelete line
ccNormalClear line and enter Insert mode
uNormalUndo
pNormalPaste from clipboard
EscNormalQuit

All global shortcuts (Ctrl+*, Alt+*, F1, Tab) work in both modes.

Engines

EngineFeaturesDependencies
Rust regex (default)Fast, linear time, UnicodePure Rust
fancy-regex+ lookaround, backreferencesPure Rust
PCRE2+ possessive quantifiers, recursion, conditionalsRequires libpcre2

Comparison

vs. terminal alternatives

Featurergxregex-tuirexi
Real-time matchingYesYesYes
Multiple engines321
Capture group highlightingYesNoNo
Plain-English explanationsYesNoNo
Replace/substitutionYesNoNo
Match clipboard copyYesNoNo
Undo/redoYesNoNo
Whitespace visualizationYesYesNo
Mouse supportYesNoNo
Regex flags toggleYesYesNo
Stdin pipe supportYesYesYes
Built-in recipe libraryYesNoNo
Vim keybindingsYesNoNo
Non-interactive batch modeYesNoNo

vs. regex101.com

regex101.com is the more capable tool overall — it has 8 engines, step-through debugging, code generation, shareable permalinks, and a community pattern library. rgx doesn't try to replace it. Where rgx is useful instead:

  • Offline/remote work — no browser or internet needed
  • Pipeline integrationecho data | rgx -p 'pattern' | next-command — non-interactive batch mode with proper exit codes
  • Engine-specific testing — test against Rust's regex crate directly (regex101 doesn't have this engine)
  • Workspace save/restore — save your session and pick up later

Configuration

rgx looks for a config file at ~/.config/rgx/config.toml:

default_engine = "rust"  # "rust", "fancy", or "pcre2"
vim_mode = false          # enable vim-style modal editing

Contributing

See CONTRIBUTING.md for details.

License

Licensed under either of

at your option.

SEE ALSO

clihub3/15/2026RGX(1)