Skip to content

vitor-mariano/regex-tui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Regex TUI

A terminal user interface (TUI) application for testing and visualizing regular expressions in real-time.

Features

  • 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

Demo

Demo

Installation

Using go install

The simplest way to install regex-tui is using go install:

go install github.com/vitor-mariano/regex-tui@latest

This will install the binary to your $HOME/go/bin directory. Make sure this directory is in your PATH.

Arch Linux

regex-rui is available on Arch Linux through AUR. You can use yay or any other AUR helper you prefer:

yay -S regex-tui

Manual Installation with Make

Clone the repository and use Make to build and install:

git clone https://github.com/vitor-mariano/regex-tui.git
cd regex-tui
make install

This will compile the application and install it to $GOPATH/bin/regex-tui.

Requirements

  • Go 1.25 or later

Usage

Simply run the command:

regex-tui

The 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

Command-Line Options

regex-tui supports several command-line flags to customize the initial state:

Available Flags

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 / -t flag cannot be used and will result in an error.

Examples

# 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 --regexp2

Whitespace Visualization

Invisible 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.

Keyboard Shortcuts

  • 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 $EDITOR environment variable)
  • Esc or Ctrl+C: Exit the application

Roadmap

  • Add mouse support

Development

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 vhs

License

This project is open source and available under the MIT License.

About

A simple TUI to visualize regular expressions right in your terminal.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors