A regex tester lets you write a regular expression, run it against sample text, and see exactly what it matches — instantly and without touching your codebase. That feedback loop is the difference between guessing at a pattern and knowing it works. A good regex tester online highlights every match, breaks out the capture groups, counts the hits and tells you plainly when the pattern is invalid. This regular expression tester does all of that in the browser, so you can iterate on a pattern in seconds and paste a proven version into your application. The guide below explains what regular expressions are, the syntax you will use every day, how the flags change behaviour, and the traps — like catastrophic backtracking and JavaScript-versus-PCRE differences — that catch people out.
What is a regular expression?
A regular expression — regex or regexp for short — is a compact string that describes a search pattern. Instead of looking for one fixed piece of text, a regex describes a shape of text: “three digits, a dash, then four digits,” or “anything that looks like an email address.” Engines in virtually every programming language, database and text editor can take that pattern and find, validate, extract or replace matching text.
Regular expressions power an enormous range of everyday tasks: validating form input, parsing log files, extracting data from scraped pages, find-and-replace across a codebase, URL routing, and data cleaning. The skill that separates people who fight with regex from people who wield it is simply a tight feedback loop — and that is exactly what a regex checker gives you. You change one character, you see the match set change, you learn. Paste a pattern and some representative text into the tool above and the rest of this page will make a lot more sense.
Regex syntax basics
Most of a regex is made of a handful of building blocks. Learn these five categories and you can read and write the large majority of patterns you will meet.
Character classes
A character class matches any one character from a set. Square brackets define your own: [aeiou] matches a single vowel, and [a-z0-9] matches one lowercase letter or digit. A caret inside the brackets negates it, so [^0-9] matches any character that is not a digit. Several classes are so common they have shorthands: \\d is a digit, \\w is a word character (letter, digit or underscore), \\s is whitespace, and the uppercase versions (\\D, \\W, \\S) are their negations. A bare dot . matches any character except a newline.
Quantifiers
Quantifiers say how many times the preceding token may repeat. * means zero or more, + means one or more, and ? means zero or one (optional). For precise counts, braces take over: {3} means exactly three, {2,5} means two to five, and {2,} means two or more. So \\d{3}-\\d{4} matches a seven-digit phone fragment like 555-0132.
Anchors
Anchors match a position rather than a character. ^ anchors to the start of the string and $ to the end, so ^\\d+$ matches a string that is only digits. The word boundary \\b sits between a word character and a non-word character, which is how you match whole words — \\bcat\\b finds “cat” but not “category.” With the multiline flag, ^ and $ match at every line break instead of only at the very ends.
Groups and alternation
Parentheses group part of a pattern so a quantifier can apply to the whole group and so you can capture what it matched: (ab)+ matches “ababab.” The pipe | is alternation, a logical OR: cat|dog|fish matches any one of the three. Combine them, as in (jpe?g|png|gif), to match a set of file extensions. Every match you run in the tool above lists the contents of each group so you can confirm you are capturing the right slices.
Regex flags, one by one
Flags are single letters appended after the closing slash that change how the whole pattern is applied. JavaScript supports six, and the tester exposes all of them as toggles:
- g (global): find every match in the string, not just the first. Without it, most operations stop at the first hit. This is the flag you will toggle most.
- i (ignore case): match without regard to upper or lower case, so /hello/i matches “Hello” and “HELLO.”
- m (multiline): make ^ and $ match at the start and end of each line, which is essential when parsing multi-line logs or text blocks.
- s (dotall): let the dot . match newline characters too, so a pattern can span multiple lines.
- u (unicode): treat the pattern as a sequence of Unicode code points, enabling \\u{...} escapes and correct handling of characters outside the basic plane, such as emoji.
- y (sticky): match only starting at the engine’s current position, with no skipping ahead — useful for tokenizers that walk through a string piece by piece.
Flags are cheap to experiment with. If a pattern is not matching what you expect, toggling g, i and m in the tool is often the fastest way to see what is going on.
Capture groups vs non-capturing groups
Parentheses do two jobs at once: they group tokens and they capture what matched. A capture group stores its matched text so you can read it back — as $1, $2 and so on in a replacement, or as array elements in code. In (\\d{4})-(\\d{2})-(\\d{2}), the three groups give you year, month and day from a date.
Sometimes you need the grouping but not the capture — for example to apply a quantifier to an alternation without cluttering your results with extra groups. That is what a non-capturing group (?:...) is for. You can also name a group with (?<year>\\d{4}) and read it back by name, which keeps complex patterns readable. The tester lists both numbered and named groups for every match, so you can confirm your extraction is landing on the right text.
Lookahead and lookbehind
Lookarounds are zero-width assertions: they test whether something does or does not appear next to the current position, without consuming any characters. A positive lookahead (?=...) matches only if the pattern inside follows; a negative lookahead (?!...) matches only if it does not. For example, \\d+(?= dollars) matches the number in “100 dollars” but leaves the word out of the match.
The mirror images are lookbehind (?<=...) and negative lookbehind (?<!...), which assert what comes before the position. Lookbehind is widely supported in modern JavaScript engines but not in every regex flavour or older runtime, so if your pattern must run elsewhere, confirm support there. Lookarounds are powerful for password rules, conditional matches and extracting values that sit next to fixed markers.
Common patterns: email, URL, phone and date
You rarely need to invent patterns from scratch — a handful cover most real work. The tool above ships with loadable examples; here is what each one is doing.
- Email: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,} covers the vast majority of real addresses. No regex perfectly matches the full email specification, so use a pragmatic pattern and confirm with a verification email.
- URL: a pattern starting https?:\\/\\/ followed by a host and optional path matches web links. URLs vary wildly, so decide whether you need to be strict or forgiving before tightening it.
- Phone: \\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4} handles common US formats with or without parentheses and separators. International numbers need a looser or locale-specific pattern.
- Date: \\d{4}-\\d{2}-\\d{2} matches ISO dates like 2026-10-17. Note that a regex checks shape, not validity — it will happily match 2026-13-40, so validate the actual values in code.
Load any of these into the tester, swap in your own sample text, and tweak until the highlights land exactly where you want. That hands-on loop is far faster than reading a reference and hoping.
JavaScript regex vs PCRE and other flavours
There is no single universal regex. Each language implements its own flavour, and the differences bite when you copy a pattern between them. This tool uses the native JavaScript RegExp engine, which follows the ECMAScript standard — the same one Node.js and every browser run. If you are writing front-end or Node code, what you see here is exactly what you will get.
If your target is Python (the re module), PHP or Perl (PCRE), Java, Go (RE2) or .NET, watch for a few recurring differences: named-group syntax varies ((?<name>...) versus (?P<name>...)), some flavours support possessive quantifiers and atomic groups that JavaScript does not, Go’s RE2 deliberately omits backreferences and lookarounds to guarantee linear-time matching, and escape handling for literal characters can differ. When you move a pattern across languages, treat this tester as a reliable guide for the JavaScript side and verify the edge cases in the destination engine.
Catastrophic backtracking and performance
Most regex runs in a blink, but a badly shaped pattern can take exponential time on certain inputs — a failure mode called catastrophic backtracking. It happens when quantifiers nest or overlap in ambiguous ways, like (a+)+$ or (.*)*, forcing the engine to try an explosion of combinations before it gives up. On a long non-matching string this can freeze a thread for seconds or minutes, and attackers exploit it deliberately as a ReDoS (regular-expression denial-of-service) attack.
You avoid it with a few habits: make quantifiers as specific as you can, prefer precise character classes over .*, avoid nesting one quantifier directly inside another, and anchor patterns where possible. Where your engine supports them, atomic groups and possessive quantifiers stop the backtracking entirely. The safest check is empirical — test any pattern that will see untrusted input against long, deliberately awkward strings and make sure it stays fast. A pattern that is correct but slow is still a bug waiting to happen in production.
Escaping special characters
Many characters carry special meaning in a regex: . * + ? ( ) [ ] { } ^ $ | \\ /. To match one of them literally, escape it with a backslash. To match an actual dot you write \\., and to match a literal opening parenthesis you write \\(. Forgetting this is the single most common beginner mistake: a pattern like 3.14 matches “3x14” too, because the unescaped dot means “any character.” Write 3\\.14 to match only the number.
Inside a character class the rules relax — most special characters lose their meaning between [ ], so [.+*] matches a literal dot, plus or asterisk. The characters you still need to handle carefully there are the hyphen (place it first or last to avoid making a range), the caret (which negates if it is first), and the closing bracket. When in doubt, paste the pattern into the tester and confirm it matches the literal characters you intended and nothing more.
Matching, extracting and replacing
Once a pattern is correct, you will use it in one of three ways, and it helps to know which the tester is simulating. Matching simply asks whether the text contains the pattern and where — that is the match count and highlighting you see above. Extracting pulls the matched text, or specific capture groups, out for use elsewhere; the per-match group list is exactly what your code receives from a method like String.matchAll in JavaScript. Replacing swaps matched text for something new, where capture groups are referenced as $1, $2 or by name.
A common real-world example ties these together. Say you have a list of dates in YYYY-MM-DD form and need them as DD/MM/YYYY. The pattern (\\d{4})-(\\d{2})-(\\d{2}) captures the three parts, and a replacement of $3/$2/$1 reorders them. Test the match side here first — confirm the three groups land on year, month and day for every row of your data — and you can trust the replacement in your editor or script. Getting the match right in a regex debugger before you run a destructive find-and-replace across a whole project is the difference between a clean refactor and a messy one.
How to use this regex tester
The workflow is deliberately simple. Type or paste your pattern in the top field and toggle the flags you need. Paste the text you want to search into the test-string box below. As you type, the tool recomputes on every keystroke: it highlights each match in your text, lists every match with its index and capture groups, and shows a running match count. If your pattern has a syntax error, you get the exact JavaScript error message instead of a crash, so you know precisely what to fix.
Start from one of the example patterns if you are learning, then change it piece by piece and watch the highlights respond — that is the fastest way to build intuition. Because everything runs in your browser, you can test patterns against confidential logs, customer data or unpublished code without any of it leaving your machine. When your pattern is doing exactly what you want, copy it out and drop it into your code. For the rest of the free toolkit — from a JSON-LD schema generator to a word counter — head to the free SEO tools index.