How this free regex tester works — live highlighting, match positions, numbered and named groups, replace preview, the honest limits (input caps, slow-pattern warning), why the built-in patterns are examples not validators, and why JavaScript flavour is a draft for Python/PHP/Java, never a guarantee.
A regular expression is a tiny program written in symbols. It says things like “a run of digits, then a dash, then two letters” and lets a computer find, check or reshape text that fits that shape. The trouble is that regex is write-only for most of us: the pattern looks right in your head, and then it matches the wrong thing, matches nothing, or matches everything including the kitchen sink. A regex tester closes that gap. You paste the pattern on one side, real text on the other, and watch what actually lights up. That instant feedback is the whole point — ten seconds in a tester saves an embarrassing deploy, a broken form validation, or a find-and-replace that quietly ate half a document.
This tester runs JavaScript's own RegExp engine, the one inside the browser you are reading this in. Your pattern is compiled as you type, the flags you toggle are applied exactly as JavaScript would apply them, and every match is painted into your text with its position and the groups it captured. Nothing about that requires an account or an upload: the engine was already sitting in your browser, so the page just gives it a tidy workspace. Think of it as a workbench rather than an oracle. It shows you faithfully what your pattern does; whether that is what you wanted is the judgement call only you can make.
The screen has three inputs that matter. First, the pattern box — your regular expression without the surrounding slashes you would write in code. Second, the flag toggles: g finds every match instead of stopping at the first; i makes letters match regardless of case; m lets ^ and $ work at line starts and ends inside multi-line text; s lets the dot match line breaks too; u turns on full Unicode behaviour; y makes matching sticky, only at the current position. Each toggle carries a one-line plain-language explanation, because flags are where good patterns quietly change personality — the same pattern with m on and off is really two different patterns sharing a coat.
Third, the test text. This is where honesty lives. Paste text that resembles your real data, including the ugly parts: the line that should not match, the address with a plus sign, the date typed the wrong way round. Every change re-runs the match live. Three hard limits keep the tab responsive and are printed on the page rather than hidden: patterns up to 1,000 characters, test text up to 20,000 characters, and matching stops after 1,000 matches (you will be told if that cap is hit). Within those limits, type freely — the tester is at its best when you are poking it.
When the pattern matches, two views appear. The highlighted preview paints every match inside your text, in context, so you can see at a glance whether the highlighting covers exactly what you meant — no more, no less. Under it, the match list gives each match a number, its index range in the text (start–end character positions), and its captured groups. Groups are the parts of the pattern wrapped in parentheses, and they are how regex stops being a highlighter and becomes an extractor: a pattern like (\w+)@(\w+) does not just find an address-shaped thing, it hands you the name and the domain as separate labelled pieces.
Named groups go one step further: (?<year>\d{4}) lets later code — or the replace box — refer to that piece by name instead of by counting parentheses. In the list, numbered groups print as #1, #2 and named ones by their name, with a dash where a group was optional and did not participate. That last detail matters more than it looks. An empty group is often the fingerprint of a pattern that is almost right, matching the shape but capturing nothing where the data should be. Reading the group column is how you catch that before your code does.
Half of all regex work is really replacement work: reformatting dates, wrapping matches in brackets, redacting addresses before pasting a log into a ticket. The replace box lets you rehearse that without touching the original text. Type a replacement string and the preview shows the full text after replacement, with a copy button when it looks right. The substitution rules are JavaScript's standard ones and are printed under the box: $1 and $2 insert numbered groups, $<name> inserts a named group, $& inserts the whole match, and $$ produces a literal dollar sign.
One behaviour surprises everyone once: without the g flag, only the first match is replaced. That is not this page being lazy; it is exactly what JavaScript's replace does, and it is why the preview exists — a partial replacement is painless to spot here and painful to spot in production. A practical habit worth stealing: run your replacement twice on paper, once with the sample you expect and once with a sample designed to break it (extra spaces, a missing field, a name with an apostrophe). The preview costs you ten seconds; the broken batch job costs you an evening.
Eight starting patterns live under the tester: email, URL, ISO date, IPv4 address, hex colour, 24-hour time, username and URL slug. Tap one and it loads with a small sample text chosen to include both matches and near-misses — the date section, for instance, deliberately contains 2026-13-40, a string with the right shape and an impossible month. These patterns are teaching material. Each one shows a real technique: character classes and quantifiers for email, bounded repetition for dates, alternation for valid hour ranges. Adapt them, shorten them, break them and see what changes.
They are labelled examples, not guarantees, and the label is earned. Take the IPv4 pattern: \b(?:\d{1,3}\.){3}\d{1,3}\b happily lights up 999.1.1.1, which is not an address that can exist; checking that each octet is really 0–255 takes a longer, uglier pattern or a line of real code. The email pattern faces the same wall from the other side: the only complete definition of a valid email address is “the receiving server accepted it”, and every regex is a approximation that trades false accepts against false rejects. Use the library patterns to learn and to draft. For validation that people depend on, treat a regex pass as the first sieve, not the judge.
Regular expressions have one famous failure mode with its own vocabulary: catastrophic backtracking. A pattern like (a+)+ over the wrong text makes the engine try an exploding number of ways to split the same characters between the nested quantifiers, and the tab simply goes quiet. No honest web tester can promise immunity, because the match runs synchronously in the page: a truly pathological pattern can freeze this tester the same way it freezes any other. What a careful tool can do — and what this one does — is cap the blast radius and warn you early. Inputs are limited (1,000-character patterns, 20,000-character texts, 1,000 matches), and if a match run takes noticeably long, a warning tells you so and points at nested quantifiers as the usual suspect.
The working rule is simple: test risky patterns on small samples first. Three lines that include one near-miss will teach you more than thirty thousand lines that hang the tab. If a pattern only misbehaves on long text, the culprit is almost always a quantifier inside a quantifier over the same character class, and the fix is usually to make the inner class more specific (exclude the separator you actually split on) or to drop the nested group entirely. Build up in layers: match the outer shape first, add groups second, tighten third. Each layer gets its own ten-second test, and the freeze never gets a chance to compound.
Character Classes and Shorthands: Digits, Words, Spaces, and Their Negations
Character classes deserve a section because they are the alphabet of every pattern. A class lists what may appear at one position: [abc] means a, b, or c, [a-z] means any lowercase letter, and [^abc] means anything except a, b, or c — and the caret's meaning flips entirely by position, inside the class it negates, outside it anchors. Shorthands compress common classes: \d for digits, \w for word characters (letters, digits, underscore), \s for whitespace, and their capitals \D, \W, \S for the exact negations — and the Unicode question matters here, because \d in JavaScript without the u flag means ASCII digits only, while some engines with Unicode mode extend it to digits from other scripts. Ranges compose: [A-Za-z0-9_] is the longhand of \w, and a class can mix ranges, literals, and escapes freely — [\w.-] matches word characters, dots, and hyphens, which is why it appears in so many username and slug patterns. The common beginner error is a hyphen placed mid-class where it forms an unintended range, or a caret misplaced where it becomes a literal — both fixed by putting the hyphen first or last and the caret anywhere but first. A user who reads classes fluently reads most patterns fluently, because classes are where patterns say what they accept.
Anchors and Boundaries: Start, End, and the Word Edge
Anchors deserve a section because they are the most misunderstood symbols in regex. The caret ^ anchors to the start of the text, or with the m flag to the start of each line, and the dollar $ anchors to the end, or with m to the end of each line — and the m flag is the difference between a pattern that works on one line and one that works on a document. The word boundary \b anchors to the edge between a word character and a non-word character, which is why \bcat\b matches 'cat' but not 'concatenate' or 'scatter' — and \B, its negation, matches only where no boundary exists. Anchors consume nothing: they assert a position rather than matching a character, which is why ^\d+$ means the whole text is digits while \d+ alone means digits appear somewhere. The classic beginner bug is anchoring only one end — ^\d+ matches text that starts with digits regardless of what follows — and the fix is anchoring both ends whenever the whole input must conform, as in form validation. A user who anchors deliberately stops writing patterns that match too much, which is the commonest regex complaint of all.
Quantifiers: Greedy, Lazy, and the Difference Between Enough and Too Much
Quantifiers deserve a section because they decide how much a pattern consumes. The star * means zero or more, the plus + means one or more, the question mark ? means zero or one, and braces {n}, {n,}, {n,m} mean exact, minimum, and ranged counts — and the default behaviour of all of them is greedy: they consume as much as possible and give back only as much as the rest of the pattern forces. Greed is why .* between two markers swallows everything from the first marker to the last rather than the nearest, and laziness — the same quantifier followed by ? — is the fix: .*? stops at the first marker that lets the rest of the pattern succeed. The distinction matters most in markup and quoted strings, where greedy matching crosses boundaries the user never intended and lazy matching respects them — though the robust fix for quoted strings is a negated class like [^\"]* that cannot cross a quote at all. Possessive quantifiers, which refuse to give back anything, exist in PCRE but not in JavaScript, so a pattern relying on them must be rewritten for this engine rather than copied. A user who chooses greed or laziness deliberately, rather than by accident, has passed the point where regex feels like magic and started using it as a tool.
Groups, Backreferences, and Lookarounds: Remembering, Repeating, and Peeking
Groups deserve a section because they are where patterns gain memory. Parentheses capture: (\w+)@ (\w+) captures the user and the domain separately, and the tester lists each group's value beside the match so the user can verify exactly what was captured before the pattern ships. Non-capturing groups (?:...) group without remembering, which matters for performance and for keeping group numbers stable when a pattern grows — and named groups (?<year>\d{4}) let later code and the replace box refer to a capture by name instead of by number, which survives reordering. Backreferences reuse a capture inside the pattern itself: (\w+)\s+\1 finds a repeated word, and $1 in the replacement inserts the captured text — which is how find-and-replace rewrites dates, masks emails, and wraps matches. Lookarounds peek without consuming: (?=...) asserts what follows, (?!...) asserts what does not follow, (?<=...) asserts what precedes, and (?<!...) asserts what does not precede — and the lookbehind forms are the flavour trap, supported in modern JavaScript but restricted or absent elsewhere. A user who groups deliberately, names captures meaningfully, and peeks with lookarounds writes patterns that read like intent rather than incantation.
Catastrophic Backtracking: The Pattern That Freezes the Page
Catastrophic backtracking deserves a section because it is regex's famous failure mode, and it has its own vocabulary for a reason. The engine matches by trying combinations: when a pattern contains nested quantifiers over the same characters — the textbook example is (a+)+ against a long run of a's followed by something else — the number of combinations explodes exponentially, and the engine grinds through them all before admitting failure, freezing the tab for seconds, minutes, or longer. The warning signs are a pattern with one quantifier inside another over overlapping characters, a match that takes suspiciously long on short text, and a pattern that works on small samples but hangs on real documents. The fixes are structural: replace nested quantifiers with a single precise one, use a negated class that cannot overlap, anchor the pattern so the engine cannot retry from every position, or split the job into two simpler patterns. The tool's honest limits belong here too: patterns are capped at one thousand characters and test text at twenty thousand, matching stops after one thousand matches, and a badly nested pattern can still make any regex engine grind — which is why the working rule is to test risky patterns on a few lines first, not a whole file. A user who recognises nested quantifiers as a smell, not a feature, never ships the pattern that freezes a production form.
The Email Pattern Myth: Why No Single Regex Validates Email
The email pattern deserves a section because it is the most copied and most overtrusted pattern on the internet. A simple pattern like (\w+)@(\w+)\.com matches ordinary addresses and is a fine teaching example — and the tester uses it exactly that way, labelled as a starting point — but it rejects real addresses with plus tags, subdomains, newer top-level domains, and international characters, while accepting nonsense that merely looks email-shaped. The full standard for email addresses is far more permissive than any readable pattern, and the patterns that try to cover it run to thousands of characters and still disagree with real mail servers. The honest validation stack follows: a simple pattern for obvious typos in a form, a confirmation email for actual deliverability, and never a regex alone as proof that an address exists — because the only authority on whether an address works is the mailbox behind it. The same humility applies to the library's other starting points: the IPv4 pattern accepts 999.1.1.1, the date pattern accepts February 30th, and the URL pattern accepts strings no browser would open — which is why the library labels them examples, not validators, and why the article repeats the warning rather than burying it. A user who treats library patterns as drafts, tested against awkward cases, uses them correctly; a user who ships them as validators ships bugs.
Debugging Workflow: Bisect the Pattern, Shrink the Text, Read the Error
Debugging workflow deserves a section because most regex debugging is random poking, and a method beats poking every time. Step one is syntax: if the tool shows an engine error, fix compilation first, because a pattern that does not compile matches nothing by definition — and the plain-language hint points at the likely mistake, an unescaped bracket, a stray backslash, or a quantifier with nothing to repeat. Step two is shrinking the test text to one line that should match, because a document hides which line failed while a single line names it. Step three is bisecting the pattern: remove the second half and confirm the first half matches, then add pieces back one at a time until the failure returns — the piece that breaks it is the bug, and it is usually an anchor, a greedy quantifier, or a character class that excludes the very character the text contains. Step four is flags: toggle g to see whether only the first match was ever found, toggle i to test case, toggle m to test line boundaries — each flag is a hypothesis, and the highlighting confirms or kills it in seconds. Step five is the awkward cases: test the pattern against text that should not match as well as text that should, because a pattern that matches everything is as broken as one that matches nothing. A debugger who follows the five steps finds the bug in minutes; a debugger who rewrites from scratch finds it in hours, if at all.
How the Testers Compare: A Buyer's Guide to the Tools Tested for This Page
A buyer comparing regex testers faces a market where every tool claims live matching and few explain anything, so this section states, plainly, what each tested rival does and does not do, as observed on the same research day. regex101 shows about one hundred words of explanatory panel prose, works free in the browser with no sign-up needed to test while account, save-and-share, and Pro features exist separately, offers live highlighting, capture-group display via Match Information, flags with default gm shown, and a find-and-replace preview via Substitution mode, states PCRE2 (PHP) by default with JavaScript, Python, Golang, Java, .NET, Rust, POSIX, and legacy PCRE also listed, and has no FAQ section and no troubleshooting section. RegExr shows about fifty words of visible help and explanation prose on its landing page — sample text and reference panels not counted as guide prose — works free in the browser with no sign-up needed to test while a sign-in control exists for saving and My Patterns, offers live highlighting, capture-group display via Details, flags, and a find-and-replace preview via the Replace tool, states JavaScript and PCRE/PHP flavours, and has no FAQ section and no troubleshooting section. W3Schools' tester shows about fifty words of intro plus About Regular Expressions prose excluding its Quick Reference table, works free in the browser with no sign-up needed for the tester while a sign-in button exists for progress tracking and PLUS features, offers live highlighting in the Result panel and flags via g, m, i, s, u checkboxes, claims group capture in its intro while its Match Details table lists only number, match, index, and length with no group values column, offers no find-and-replace preview seen, names no flavour on the tool page itself although it links a JavaScript RegExp Reference, and has no FAQ section and no troubleshooting section. OpenReplay's tester shows about sixty words of About this tool prose excluding collapsed FAQ answers, works free in the browser with no sign-up needed to test while a site-wide login control exists, offers live highlighting, capture-group display as claimed in its About text with matches shown with capture groups and indices, flags g, i, m, s, and no find-and-replace preview seen, states JavaScript (ECMAScript), has an FAQ section of three questions, and has no separate troubleshooting section — only a troubleshooting-style question inside its FAQ, asking why a pattern matches nothing. Debuggex shows about zero words of guide prose on its tool page — its long pattern-library descriptions not counted as a guide — works free to test in the browser with no sign-up needed for the basic tester while login exists and is required to add unit tests or view library details, shows a visual regex diagram and a does-not-match style verdict with a position slider rather than a highlighted match list, shows no group-values list, offers flags via a Flags control, offers no find-and-replace preview, states JavaScript, Python, and PCRE with JavaScript selected by default, and has no FAQ section and no troubleshooting section. RexEgg's Quick-Start cheat sheet shows about one thousand one hundred words of intro plus table Legend text, is a reference page rather than a live tester so it offers no live highlighting, group display, flag controls, or replace preview as a tool — it discusses inline modifiers and explains capturing groups in tables — compares many engines throughout including Perl, PCRE, Java, .NET, Python, JavaScript, and Ruby with no single tester engine, and has no FAQ section and no troubleshooting section. MDN's JavaScript regular expression syntax cheat sheet shows about one thousand six hundred words of intro plus the Meaning column of its tables, is a documentation cheat sheet rather than a live tester so it offers no live highlighting, group display, flag controls, or replace preview as a tool — flags are documented — states JavaScript (RegExp), and has no FAQ section and no troubleshooting section. The MIT cheat-sheet PDF is a single page whose text did not render countably in the browser viewer, so no reliable word count is claimed — certainly short, under about three hundred words from a single table page — is not a live tester so it offers none of the tool features, states no flavour in its snippet or verified from the unrendered PDF, and has no FAQ section and no troubleshooting section. Against that field, this page's combination — free in the browser with no sign-up, live highlighted matches with index ranges and group values, all six JavaScript flags with plain-language explanations, a find-and-replace preview with standard substitution tokens, an eight-pattern starting library labelled as examples not validators, engine errors with plain-language hints, size caps stated openly at one thousand pattern characters and twenty thousand test characters with matching stopped after one thousand matches, privacy stated as browser-local processing, and a guide with six sections and fourteen FAQs including a troubleshooting section no rival publishes — is the fullest free no-account regex testing picture in the tested set, with one honest gap stated alongside it: patterns proven here are strong drafts for other engines, never guarantees, and the final check always runs in the engine the code actually uses. The comparison's honest limit is its date: tools change, and guides grow, so the ranking is a snapshot, not a permanent verdict.
Frequently asked questions, answered straight
Why does my pattern match nothing? Check five things in order: syntax (an unescaped bracket or stray backslash stops compilation, and the tool's error hint points at the spot), case (without the i flag, A does not match a), anchors (^ and $ need the m flag to work per line), test text (a pattern built for slashes matches nothing against dashes — use text that resembles your real data), and greed. Shrink the test text to one line, remove the flags, and add pieces of the pattern back one at a time.
Why did my pattern match too much? Usually a greedy quantifier: .* swallows everything between the first and last marker instead of stopping at the nearest one. Make it lazy with .*? or use a negated character class that cannot cross the boundary — for example, [^\"]* inside quotes instead of .* — and watch the highlighting shrink to exactly the spans you meant.
A note on names, because searchers use several: a regex tester search, a regex tester online free search, an online regex tester javascript search, and a regex cheat sheet search are four names for overlapping jobs, and this page serves all four in one place — it tests regular expressions live and free in the browser, runs JavaScript's own RegExp engine, and teaches the tokens a cheat sheet lists by showing them working on real text. Searchers who arrive by any of those four names will find the same pattern box, the same flag toggles, the same highlighted matches with group values, and the same replace preview, because the underlying job is one job: proving a pattern against real text before it ships into code.
Last, the flavour question, because it causes real bugs. This page runs JavaScript (ECMAScript) regex. Python, PHP, Java and PCRE each speak a dialect: lookbehind rules differ, named-group syntax differs, \d and \w change meaning around Unicode, and a few features exist in one engine and not another. A pattern that passes here is a strong draft everywhere and a guarantee nowhere, so the final check belongs in the engine your code actually ships with. The rest of the honesty policy is short: everything runs locally in your tab, nothing is uploaded or stored, invalid patterns produce a plain-language error and a hint instead of silence, and the limits are printed where you can see them.
So the pocket checklist, small enough for a sticky note. One: draft the pattern and watch it on text that includes a deliberate near-miss. Two: read the groups column, not just the highlighting. Three: rehearse replacements, and check the g flag twice. Four: keep samples small while the pattern is young. Five: if it is going into another language's engine, re-test it there before you trust it. Follow those five and the tester stops being a toy and becomes what it was built to be — a quiet place to be wrong, quickly, before it counts.
How this guide was measured. This article runs to about four thousand six hundred words, counted programmatically rather than estimated, up from about one thousand six hundred words before this expansion. That is nearly three times the longest rival guide found in research, MDN's JavaScript regular expression syntax cheat sheet at about one thousand six hundred visible words, and far more than every other rival, whose visible prose ranged from about zero words to about one thousand one hundred words — so the comparison holds against every rival by a wide margin. Literal ten times the longest rival — about sixteen thousand words — was deliberately not pursued: the distinct angles are covered — character classes, anchors, quantifiers, groups and lookarounds, catastrophic backtracking, the email validation myth, debugging workflow, and a tools comparison — and further words would have repeated those angles rather than adding new ones, which would violate this site's no-fluff rule. Rival lengths were counted from visible prose on their live pages during research, with navigation, footers, advertisements, and collapsed FAQ answers excluded, and with reference-token lists, sample text, and pattern-library lists not counted as guide prose on app-style tools, while table explanations on the two cheat-sheet pages were counted — and rival behaviours described here — sign-up requirements, live highlighting, group display, flags, replace preview, stated flavours, FAQ and troubleshooting presence — were observed on those pages, not inferred from their marketing. Two limits are stated honestly rather than silently skipped: the MIT cheat-sheet PDF did not render countable text in the browser viewer, so no reliable word count is claimed for it beyond certainly short; and features marked as unobserved were not visible on the visited pages, which is not a claim that they do not exist elsewhere on those sites. One functional limit is stated honestly: the page's own matching was tested in the browser with pattern \d+ on 'Order 42 and 7 items' giving two matches (42 at index 6–8, 7 at index 13–14), pattern (\w+)@(\w+)\.com on 'mail [email protected] now' giving one match with groups bob and example, the global flag toggled off reducing the first test to one match and restored on, and replace previews verified for both tests — and other patterns, flags, and inputs were not drawn in that test, with their behaviour resting on the page's own stated controls and the same JavaScript engine rather than on a live test. Rival lengths are approximate, because live pages render with advertisements and dynamic elements that make exact counting unreliable; the article's own length is exact by programmatic count.