Regex Tester

Test regular expressions live in your browser with syntax highlighting and an instant match list, no installation required, right in the window.

The result will appear here …

How to use this tool (video)

This video is hosted on YouTube. When you play it, data may be sent to Google.

Regex Tester: Test and Debug Regular Expressions

Test regular expression patterns live, highlight matches, and preview replacements. Enter a pattern, flags, and sample text to inspect every match directly in your browser. No test data is sent to a server.

How the tester works

The pattern is executed as a JavaScript RegExp. Flags control its behaviour: g (all matches, not just the first), i (ignore case), m (anchors apply per line), s (dot also matches line breaks), u (Unicode) and y (sticky). The tool keeps only valid flag characters, highlights matches in the text, and lists each match with its position and length. Replacement mode adds a preview of the transformed text.

A worked example: The default pattern \d{3,} (three or more digits in a row) runs against the sample text. From the line "Meine Telefonnummer ist 0421-123456 ... Der Preis beträgt 99,95 € ... 12345 ... 2026-08-01" it matches 0421, 123456, 12345 and 2026. The short numbers 99, 95, 3 and 42 are not found because they have fewer than three digits.

Anchors, character classes and escaping

  • Anchors: ^ (start), $ (end). For example ^2026 only matches a line that starts with 2026.
  • Character classes: \d (digit), \w (word char), \s (whitespace), [0-9] (digit range).
  • Quantifiers: * (0 or more), + (1 or more), ? (0 or 1), {3,} (at least 3).
  • Groups: (abc) groups, (a|b) alternation, lookaheads like (?=...) check without consuming.
  • Escaping: metacharacters such as ., *, + must be escaped for literal use, for example \. for a real dot.

Important: this tester is not a tutorial

This tool tests and debugs patterns; it does not teach regex theory from scratch. It also returns results in the JavaScript dialect of RegExp. Behaviour differs between engines: what JavaScript does (lookbehind, Unicode support) is not identical to PCRE (PHP) or Python's re module. A pattern that works here may mean something different or fail elsewhere. Always double-check critical patterns in the target environment.

Typical use cases

  • Data validation test patterns for email, phone numbers, zip codes or dates
  • Text extraction find all numbers, URLs or email addresses in a text
  • Text transformation replace certain patterns with other formatting
  • Debugging find out why a regex does not produce the expected result
  • Learning understand how quantifiers, groups and lookaheads work

Understanding greedy and lazy quantifiers

By default quantifiers are greedy, taking as much as possible. In the line a="1" b="2" the pattern ".*" matches from the first to the last quote mark, that is the whole rest "1" b="2". Adding a ? makes the quantifier lazy: ".*?" stops at the first closing quote and yields only "1". This distinction is one of the most common sources of errors when writing regex, and this tester lets you try both variants directly and see the behaviour.

A practical pattern: pulling an email out of text

A typical everyday pattern is finding email addresses, for example with [a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}. It requires a local part of letters, digits and a few special characters, then the @, then a domain and finally a top-level domain of at least two letters. In the sentence "Kontakt erreichst du unter max.mustermann@example.de" you find exactly max.mustermann@example.de. You can try such patterns here with real texts and adapt them to your data.

The fastest way to learn here is experimentation: take a real text from your application, write a small pattern, and watch both the highlight and the match list update. Try removing a flag or adding an anchor to see how the result changes. This immediate feedback is what makes a tester so much quicker than guessing in code, and it is the surest way to understand how quantifiers, groups and anchors actually behave.

Frequently asked questions

How do I test a regular expression?

Enter your pattern and flags, add test text and immediately see which parts match. Matches are highlighted in color and listed with position, length and content.

Can I replace text with this tool?

Yes. In replacement mode you provide a replacement pattern and the tool shows the transformed version of your text live. This lets you verify transformations before you use them.

How do I find out why my regex does not work?

The match list shows which parts of your text match and which do not. You can adjust pattern and flags step by step and see the effect in real time. That is the fastest way to find errors.

Which flags can I use?

You can set the usual flags such as global (g), case-insensitive (i) and multiline (m). These control whether all matches are found, whether the match ignores case, and how line breaks are treated.

Does the regex here differ from other languages?

Yes. This tester uses the JavaScript engine. PCRE, Python and other languages differ in details such as lookbehind and Unicode. Double-check a pattern that works here in the target environment.

Which regex techniques can I try?

The tool supports quantifiers, groups, alternation and lookaheads as well as character classes and anchors. You can practice everything from simple patterns to complex constructs.

Are my test data sent to a server?

No. Testing, highlighting and replacing run entirely in your browser. Your patterns and test data are not transferred to any server.

Are my data stored?

No. This tool works completely in your browser. Your pattern and your test text are not transmitted to our server or stored.