A terminal user interface (TUI) application for testing and visualizing regular expressions in real-time.
- Interactive regex editor with live validation
- RE2 engine by default; regexp2 option with partial PCRE compatibility
- Multi-line text input for testing
- Visual highlighting of regex matches with alternating colors
- Whitespace visualization: spaces (
·) and line breaks (↵) are displayed as visible glyphs - Real-time feedback as you type the expression
- Clean and intuitive terminal interface
- Tab navigation between regex and text inputs
- Options dialog for toggling global and case-insensitive flags
The simplest way to install regex-tui is using go install:
go install github.com/vitor-mariano/regex-tui@latestThis will install the binary to your $HOME/go/bin directory. Make sure this directory is in your PATH.
regex-rui is available on Arch Linux through AUR. You can use yay or any other AUR helper you prefer:
yay -S regex-tuiClone the repository and use Make to build and install:
git clone https://github.com/vitor-mariano/regex-tui.git
cd regex-tui
make installThis will compile the application and install it to $GOPATH/bin/regex-tui.
- Go 1.25 or later
Simply run the command:
regex-tuiThe application will launch in full-screen mode with:
- A regex pattern input field at the top (starts with example pattern
[A-Z]\w+) - A text input area below (starts with example text "Hello World!")
- Matches highlighted in alternating yellow and blue colors
regex-tui supports several command-line flags to customize the initial state:
| Flag | Shorthand | Description |
|---|---|---|
--regex |
-r |
Initial regex pattern |
--text |
-t |
Initial text subject |
--empty |
-e |
Start with empty expression and text |
--no-global |
Disable global flag (match only first occurrence) | |
--insensitive |
Enable case-insensitive flag | |
--regexp2 |
Use regexp2 engine (partial PCRE compatibility) | |
--no-whitespaces |
Disable whitespace visualization |
Notes:
- When reading from stdin, the
--text/-tflag cannot be used and will result in an error.
# Custom regex with empty text
regex-tui -e -r "[A-Z]\w+"
# Custom regex and text
regex-tui -r "\d{3}-\d{4}" -t "Call me at 555-1234"
# Case-insensitive matching (global is enabled by default)
regex-tui -r "error" -t "Error: invalid input" --insensitive
# Match only first occurrence
regex-tui -r "foo" -t "foo bar foo" --no-global
# Use regexp2 engine with lookahead
regex-tui -r "foo(?=bar)" -t "foobar foobaz" --regexp2
# Piped text with custom regex
cat log.txt | regex-tui -r "ERROR.*"
# All flags combined
cat file.txt | regex-tui -r "\w+" --no-global --insensitive --regexp2Invisible characters are displayed as visible glyphs to help debug whitespace-sensitive regex patterns:
| Character | Glyph |
|---|---|
| Space | · |
| Line break | ↵ |
Whitespace visualization is enabled by default. Glyphs inside regex matches inherit the match highlight color; glyphs outside matches are dimmed.
To disable at launch, use --no-whitespaces. To toggle at runtime, open the options menu with Ctrl+P and toggle the "Whitespaces" option.
- Tab: Switch between regex input and text input
- Ctrl+P: Open the options dialog to toggle regex flags
- Ctrl+O: Open text content in an external editor (uses
$EDITORenvironment variable) - Esc or Ctrl+C: Exit the application
- Add mouse support
Other available make targets:
make run # Run without installing
make build # Build the binary locally in bin/regex-tui
make debug # Build with debug flags and run locally
make clean # Remove built binary
make uninstall # Remove installed binary from $GOPATH/bin
make lint # Run go vet and go fmt
make demo # Generate demo GIF using vhsThis project is open source and available under the MIT License.
