What Is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. They are used in programming for text matching, validation, search-and-replace, and data extraction. Mastering regex can save hours of manual text processing.
How to Use
- Enter your regex — Type a pattern in the input field at the top. The regex is displayed between forward slashes
/pattern/flags, just like in JavaScript. - Toggle flags — Click flag buttons to enable options:
g(global, find all),i(case-insensitive),m(multiline),s(dotall),u(unicode),y(sticky). - Enter test text — Type or paste text in the test string area. Matches are highlighted in real time as you type.
- Explore the tabs — Switch between Matches, Explain, Replace, Code, and Reference tabs for different views.
Match Highlighting
Every match in your test string is highlighted with a colored overlay. The match count and number of capture groups are shown in the stats bar above the tabs. Matches update instantly on every keystroke.
Regex Explanation
The Explain tab breaks your regex down into individual tokens and describes each one in plain English. Character classes, quantifiers, groups, lookaheads, and backreferences are all explained. Nested groups are indented for readability.
Find and Replace
The Replace tab lets you enter a replacement string and see the substituted result live. Standard backreferences are supported: $1, $2 for capture groups, $& for the full match, and $` / $' for text before and after the match.
Code Generation
The Code tab generates ready-to-use code snippets for six languages: JavaScript, Python, Java, C#, PHP, and Go. Each snippet shows how to compile the regex, find matches, and perform replacements with the correct syntax and flag mappings for that language.
Quick Reference
The Reference tab provides a cheat sheet covering character classes, quantifiers, anchors, groups, lookaround, and escape sequences. Keep it open while building your regex.
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. They are used in programming for text matching, validation, search-and-replace, and data extraction.
What does the Explain tab do?
The Explain tab breaks your regex down into individual tokens and describes each one in plain English — including character classes, quantifiers, groups, lookaheads, and backreferences.
What programming languages does code generation support?
The Code tab generates ready-to-use snippets for six languages: JavaScript, Python, Java, C#, PHP, and Go — each with the correct syntax and flag mappings for that language.
How does the Replace tab work?
Enter a replacement string in the Replace tab to see the substituted result live. Standard backreferences are supported: $1, $2 for capture groups, $& for the full match.
Is my regex or test text sent to a server?
No. All regex processing happens entirely in your browser using JavaScript's built-in RegExp engine. Nothing is sent to any server.
Tips
- Start simple and build up — test each part of your regex before combining them.
- Use the
gflag to find all matches, not just the first one. - Named groups
(?<name>...)make complex patterns easier to read. - The Explain tab is your best friend for debugging unfamiliar patterns.
- All processing happens in your browser — nothing is sent to a server.
From the build: the matcher is the browser's native RegExp engine — there is no point shipping a second one to the tab. The interesting work is the Explain tab, which is a tiny tokenizer we wrote that walks the pattern character-by-character and describes what each construct does. Code generation isn't actual transpilation; it's a set of small template functions per language because the flag letters and escape rules differ enough between, say, Python and Go that anything more clever turns into a maintenance liability. Match highlighting uses a transparent overlay aligned to the textarea via the same font metrics, which avoids the contenteditable rabbit hole entirely.
Regex Terms in Plain English
- Character class
- A bracketed set such as
[a-z]or[0-9]that matches any single character from the set. Lead with^to negate, so[^aeiou]matches any non-vowel. - Quantifier
- Symbols that say how many times the previous token must match.
*is zero or more,+is one or more,?is zero or one, and{2,5}is between two and five times. - Anchor
- A position match rather than a character match.
^binds to the start of the string (or line in multiline mode),$to the end, and\bto a word boundary. - Capture group
- A pattern wrapped in parentheses
(...)that records what it matched. Reuse the captured text later via$1,$2, and so on in the Replace field. - Lookaround (lookahead / lookbehind)
- An assertion that requires nearby text without consuming it.
foo(?=bar)matchesfooonly when followed bybar;(?<=bar)foomatchesfooonly when preceded bybar. - Backreference
- A reference back to a previously captured group inside the same pattern.
(\w+)\s+\1matches a word repeated twice in a row by using\1to refer back to the first capture.