1. Home
  2. Developer tools
  3. Regex Tester

Regex Tester

See every match highlighted as you type, with numbered and named groups and a live replacement preview.

Free, no sign-up. Runs in your browser: nothing is uploaded.

Free workspace included. Docs, spreadsheets, notes and tasks that save on your device. No sign-up.Take a look

How to use Regex Tester

  1. Enter a pattern and flags.
  2. Paste the test text.
  3. Inspect matches or try a replacement.

Features

  • Live highlighting
  • Capture and named groups
  • Flags g, i, m, s, u, y
  • Replace with $1 and $<name>

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Regex Tester is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Guide

Writing and testing regular expressions step by step

Regular expressions are compact and powerful, and easy to get subtly wrong. The reliable way to write one is against real sample text, one small piece at a time, watching what matches. This tester highlights matches as you type, lists every capture group, and previews replacements, all with the same JavaScript engine your web or Node.js code uses.

Testing a pattern

  1. Enter the pattern (without slashes) and the flags, or toggle flags with the chips.
  2. Paste test text: real data, including the edge cases you expect.
  3. Matches are highlighted, counted, and listed with their position and groups, including named groups.
  4. Try a replacement using $1, $<name> or $& and copy the result.

If the pattern is invalid, the browser’s error message appears instead, such as an unterminated group or a nothing-to-repeat error.

Build it up gradually

Start with the most specific part, check it matches, then extend it. For an ISO date such as 2026-10-12:

  1. \d{4} matches the year.
  2. \d{4}-\d{2} adds the month.
  3. (\d{4})-(\d{2})-(\d{2}) captures all three parts as groups 1 to 3.
  4. (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) names them, so the replacement $<day>/$<month>/$<year> gives 12/10/2026.

At each step, the match list confirms you’re catching what you meant and nothing else.

Flags in one line each

Flag Effect
g global Find all matches, not just the first
i ignore case A matches a
m multiline ^ and $ match at every line, not just the whole text
s dotAll . also matches line breaks
u unicode Full Unicode, needed for emoji and \p{…} classes
y sticky Match only at the current position (used in tokenizers)

Patterns worth keeping

Task Pattern
Trailing spaces [ \t]+$ with m
Repeated words (“the the”) \b(\w+)\s+\1\b with i
key=value pairs (\w+)=([^&\s]+)
Simple email shape (not full validation) ^[^\s@]+@[^\s@]+\.[^\s@]+$
Hex color #(?:[0-9a-fA-F]{3}){1,2}\b
Text inside quotes "([^"]*)"

Common traps

  • Greedy matching: ".*" on "a" and "b" matches the whole string. Use ".*?" or "[^"]*".
  • Unescaped special characters: . matches any character; write \. for a literal dot. The same goes for ? + * ( ) [ ] { } ^ $ | \.
  • Forgetting anchors: without ^ and $, a “validation” pattern accepts any text that merely contains a match.
  • Catastrophic backtracking: nested quantifiers like (\w+\s?)+$ can freeze on long, non-matching text. Make each part unambiguous.
  • Different engines: JavaScript, Python, PCRE (PHP), Java and .NET mostly agree, but advanced features differ. Re-test advanced patterns in the target language.
  • Validating email or URLs perfectly: regex can check the shape, but real validation means sending a confirmation email or parsing with a URL library.

The cheat sheet

The panel at the bottom lists the tokens you’ll reach for most: \d, \w, \s, quantifiers like + * ? {2,4}, character sets, groups and named groups, alternation and lookaheads.

Without code

For one-off edits in a document, Find and Replace supports regular expressions too, and the Diff Checker shows exactly what a replacement changed.

Who tests regular expressions

  • Developers write validation, parsing and search patterns.
  • Data analysts extract values from text exports and logs.
  • System administrators filter logs and configuration files.
  • SEO and content specialists build redirect rules and analytics filters.

A complete example: extracting order numbers from emails

Order emails contain “Order #A-48213”:

  1. Paste a few sample emails into the test text.
  2. Type the pattern Order #([A-Z]-\d{5}) with the g flag.
  3. The match list shows each order number in group 1.
  4. Add one email with an unusual format to check the pattern still matches only real order numbers.

Tips

  • Test with examples that should not match as well.
  • Keep patterns readable; a short comment in your code explains what they match.

Checked against the current version of the Regex Tester on .

Troubleshooting

It matches only the first result

Add the g (global) flag. Without it, JavaScript stops after the first match.

My pattern works here but not in Python or Java

This tester uses JavaScript regular expressions. Most syntax is shared, but lookbehind, named groups and flags differ slightly between languages.

Frequently asked questions

Will a pattern tested here work in Python, PHP or Java?

Simple patterns usually do, but engines differ. This tester uses JavaScript's engine, so it matches what browsers and Node.js do exactly. Features such as lookbehind, named-group syntax, possessive quantifiers and Unicode classes vary between languages, so re-test in the target language for anything advanced.

Why does my pattern match too much?

Quantifiers like .* and .+ are greedy - they take as much text as possible. Add ? to make them lazy (.*?), or use a more specific class such as [^"]* instead of .* when matching up to a delimiter.

How do I use a captured group in the replacement?

Refer to numbered groups as $1, $2 and so on, to named groups as $<name>, and to the whole match as $&. For example, the pattern (\w+)@(\w+) with the replacement $2:$1 turns ana@example into example:ana.

Why is my regex extremely slow on some text?

Nested quantifiers such as (a+)+ or (\w+\s?)+ can try an exponential number of combinations when a match fails - known as catastrophic backtracking. Make the pattern more specific so each character can only be matched one way.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.