explaingit

ziishaned/learn-regex

46,119Audience · vibe coderComplexity · 1/5QuietLicenseSetup · easy

TLDR

A step-by-step guide to learning regular expressions, from basic pattern matching to advanced techniques like lookahead assertions.

Mindmap

mindmap
  root((learn-regex))
    What it teaches
      Literal matching
      Character sets
      Repetition operators
      Anchors and groups
      Lookahead assertions
    How it works
      Plain-text guide
      Interactive examples
      Regex tester links
    Use cases
      First-time learners
      Quick reference
      Email validation
      Text extraction
    Audience
      Beginners
      Self-taught coders
      Anyone using regex

Things people build with this

USE CASE 1

Learn regex patterns from scratch with step-by-step explanations and interactive examples.

USE CASE 2

Validate email addresses, phone numbers, or URLs using regex patterns.

USE CASE 3

Extract specific text from larger strings using capturing groups and pattern matching.

USE CASE 4

Quickly reference a specific regex construct you encounter in code or documentation.

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial, as long as you keep the copyright notice.

In plain English

Learn-regex is a plain-text educational guide that teaches regular expressions from the ground up. A regular expression (often abbreviated \"regex\") is a pattern written in a special mini-language that lets you search for, match, validate, or extract text based on a description of what the text should look like, rather than spelling out the exact text you want. For example, instead of checking whether an email address is exactly \"[email protected]\", a regex lets you check whether any string follows the general form of an email address. The guide starts with the simplest concepts (matching literal text) and works systematically through every major building block: the dot that matches any character, character sets in square brackets that match one character from a group, repetition operators that control how many times a pattern repeats, anchors that require the match to start or end at a specific position, capturing groups that extract pieces of the match, and lookahead and lookbehind assertions that let you match text only when it is (or is not) preceded or followed by something specific. It also covers flags like case-insensitive mode and global mode. Each concept is explained with short examples that show a pattern and highlight what it matches in a sample sentence, with links to an interactive regex tester where you can experiment immediately. You would use this guide when first learning regex, it is structured to build understanding step by step rather than dump the full specification at once. It is also useful as a reference when you encounter a specific regex construct you have not seen before. The repository contains no programming code, it is a documentation-only project. It has been translated into over 15 languages and has no runtime dependencies.

Copy-paste prompts

Prompt 1
I'm new to regex. Walk me through the learn-regex guide starting with literal matching and character sets, then show me how to build a pattern to match email addresses.
Prompt 2
Using the learn-regex guide, explain how lookahead and lookbehind assertions work, and give me a real example of when I'd use them.
Prompt 3
Show me how to use the patterns from learn-regex to extract all phone numbers from a block of text using capturing groups.
Prompt 4
I found a regex pattern in code I don't understand. Using learn-regex concepts, break down this pattern step by step: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.