2026-08-07
What is a regular expression (regex)?
Learn how regex patterns match text, when developers use them, and how JavaScript flavor differs - then test patterns locally.
A regular expression (regex) is a compact pattern language for finding, validating, and extracting text. Instead of writing nested loops and string checks, you describe the shape of what you want - digits, emails, log lines, URLs - and let a regex engine search for matches.
How regex works (in one minute)
You write a pattern such as \d{3}-\d{2} and apply it to a test string. The engine walks the text and reports where the pattern matches. Special characters like ., *, and [] control wildcards, repetition, and character sets. Parentheses create capture groups so you can pull out pieces of a match.
Where developers use regex
- Form validation (email-ish checks, phone formats, IDs)
- Log and text parsing in scripts and observability tools
- Search-and-replace in editors and code migrations
- Routing rules, scrapers, and lightweight tokenizers
Flavors matter
"Regex" is not one universal dialect. JavaScript/ECMAScript, PCRE, Python, and .NET differ on lookbehind, Unicode escapes, possessive quantifiers, and more. An online tester that uses your browser's RegExp engine is ideal when you ship patterns in web apps or Node.js - and a poor fit if you need PCRE-only features.
Why test interactively
Small mistakes (a missing escape, a greedy .*, forgetting the g flag) change results dramatically. A live matcher with highlights and capture groups shortens the feedback loop before you paste the pattern into production code.
Ready to try a pattern? Test JavaScript regex live in your browser - nothing is uploaded.
Open the free regex tester →
Next reads: How to test regex online · Common regex mistakes