2025

Regex — Regex Engine in Go

A regex engine in Go: lexer, parser, and matcher with a small CLI to try patterns against text. Supports literals, quantifiers, alternation, groups, predefined classes, and escapes.

Technology Stack

Go

Overview

How it works

The pattern goes through three stages: first it is turned into tokens (like “character,” “repeat zero or more,” “or”), then those tokens are turned into a tree that represents the pattern, and finally that tree is run against your text to find a match.

What you can do with it

You can match plain text, “any character,” repeats (like “zero or more” or “one or more”), “or” between options, and groups (including non-capturing). It also supports shortcuts for digits, word characters, and spaces, plus escape sequences like newline and tab.

Current limits

Anchors (start/end of string) and character classes (e.g. “a to z”) are partly implemented. Some advanced features (backreferences, lookahead/lookbehind) exist in the code but aren’t fully wired up yet. Parser errors currently cause the program to panic.