Regex tester
Test a JavaScript regular expression and inspect matches, positions, and capture groups.
Test a JavaScript regular expression and inspect matches, positions, and capture groups.
A regular expression, or regex, is a search rule that finds text by its shape. FluffyBench's Regex tester shows what your pattern catches, where each match starts, and which pieces it saves, all in your browser.
Limits Patterns follow JavaScript's rules, so a pattern copied from another programming language may need small changes.
Say you've pasted a long email and want every order number in it. You can't search for one exact word, because each number is different. A regex lets you describe the shape instead: the word order, some spacing, then a number. Think of it as a highlighter that only marks text of that shape.
Here's that rule written as a pattern, (order)\s+(\d+), with Ignore case on, searching the text Order 42; order 7.
Order and order both count, and your text keeps its capital letter. How we measuredWant to know what \s and \d mean? Our guide to JavaScript regex patterns, flags, and groups walks through the symbols.
Here's the order-number search from start to finish, as it looks on a phone. On a wider screen, the text and the matches sit side by side.
The match card and the copied list point to the same spot in two ways. The card gives a line, and a character on that line counted from 1. The copied list gives the index: the position in the whole text, counted from 0.
Emoji can make the index jump. In our check, JavaScript counted 😀 as two positions, so the letter right after it sits at index 2. If a position looks off, FluffyBench's Unicode inspector lets you look at each character in your text.
A loose pattern can find hundreds of matches, so the tester has two limits: one for what it shows, and one for how far it searches.
FluffyBench shows the first 100 matches as cards and tells you the full count, and Copy still gives you the whole list. Here's a list of 150 order lines, typed for illustration.
More than 100 matches: the first 100 cards
If a search finds more than 5,000 matches, it stops instead. Here's a search for the letter a in a run of 5,001 of them: one match too many.
Match 5,001 found: the search stops
Here's the order pattern with its last closing parenthesis missing, (order)\s+(\d+. FluffyBench says which group is open and where.
Invalid pattern
No matches found. Check letter case first: without Ignore case, Order and order are different words.
Timed out. A pattern that runs for more than five seconds is stopped so the page stays usable. Simplify the pattern or search a shorter piece of text.
A Test button appeared. With very long text, FluffyBench stops searching as you type. Press Test when your pattern is ready.
It compares the two versions directly and marks the changes, with no pattern to write.