← Back to Tools

Regex Tester

Test regular expressions in real time

What Is a Regex Tester?

A regex tester is an interactive tool that lets you write a regular expression pattern and instantly see which parts of your test string it matches. Instead of guessing whether your pattern works, you get real-time feedback: matches are highlighted, capture groups are extracted, and syntax errors are caught before you ship code.

Our free online regex tester is built directly into the browser — no downloads, no sign-ups, no tracking. It uses the JavaScript RegExp engine, which means the syntax matches what you'll use in JavaScript, TypeScript, Python (with minor differences), and most modern languages. Whether you're validating an email input, extracting data from a log file, or cleaning up a dataset, a regex tester is the fastest way to get your pattern right.

Unlike a static code example, a live tester lets you iterate. You'll often find that a pattern works on your first test string but fails on edge cases — a live tester surfaces those failures immediately. That's why seasoned developers keep a regex tester tab open while coding, rather than trying to "write it right" on the first try.

How It Works

Using our regex tester is straightforward:

  1. Enter your pattern — Type your regular expression into the "Regex Pattern" field. Don't include the forward slashes (e.g., type \d+, not /\d+/).
  2. Select flags (optional) — Check "global" (g) to find all matches, "case insensitive" (i) to ignore case, "multiline" (m) to make ^ and $ match per line, and "dotall" (s) to make . match newlines.
  3. Provide test string — Paste or type the text you want to test against in the "Test String" box.
  4. See results instantly — Matching portions are highlighted in yellow. The "Match Count" shows how many matches were found, and "Match Details" lists each match with its position and any capture groups.

The tester updates in real time as you type — no "submit" button needed. If your pattern has a syntax error, the status box will show an error message instead of matches.

Tips for Testing Regex

Debug patterns faster and avoid common traps:

Common Regex Pitfalls

Even experienced developers hit these regularly:

How to Use This Tool

Step 1: Type your regular expression pattern into the input field. Do not include the leading and trailing slashes — just the pattern itself (e.g. [a-z]+).

Step 2: Set flags if needed. Use g for global (find all matches), i for case-insensitive, m for multiline mode, or s for dotAll mode (allows . to match newlines).

Step 3: Enter your test string in the large text area. As you type, matches are highlighted in real time.

Step 4: Review the match count and highlighted matches. Use the regex reference below if you're unsure about a pattern.

Common Regex Patterns

Pattern Meaning Example Match
[a-z]+ One or more lowercase letters hello
\d+ One or more digits 123
\w+@\w+\.\w+ Simple email pattern user@example.com
^https?:// Starts with http:// or https:// https://...
[\w\.-]+@[\w\.-]+ Better email pattern user.name@domain.co.uk

Regex Metacharacters Quick Reference

Character Meaning Example
. Any character except newline a.c matches "abc", "a c"
\d Digit [0-9] \d+ matches "123"
\w Word character [a-zA-Z0-9_] \w+ matches "hello_123"
\s Whitespace (space, tab, newline) a\sb matches "a b"
^ Start of string (or line in multiline mode) ^Hello matches "Hello world"
$ End of string (or line in multiline mode) world$ matches "Hello world"
* 0 or more ab*c matches "ac", "abc", "abbc"
+ 1 or more ab+c matches "abc", "abbc"
? 0 or 1 (or makes quantifier lazy) colou?r matches "color", "colour"
[abc] Character class (any one of a, b, or c) [aeiou] matches any vowel
(...) Capture group (\d+) captures digits

Practical Examples

Use these real-world patterns as starting points:

Pro Tip: Test these patterns in the tool above with sample text. Modify them to fit your specific use case — regex is rarely "one size fits all".

/ /
Enter a pattern to see matches

Frequently Asked Questions

What regex flavor is used?

JavaScript (ECMAScript) regex. Compatible with most modern programming languages.

What flags are supported?

g (global), i (case-insensitive), m (multiline), s (dotAll). Combine them: e.g. "gi".

Can I test regex for languages other than JavaScript?

Yes, but with caveats. JavaScript regex is very similar to Python, Java, C#, and PHP — most patterns work across all of them. However, some advanced features (like lookbehinds, which JS added in ES2018) may not work in older engines. If you're targeting a specific language, test in that language's regex tester too.

Why does my regex work here but not in my code?

Common reasons: (1) You forgot to escape backslashes in strings (in Python/Java, `\d` not `\d`), (2) You're using flags inconsistently, (3) The regex engine version differs (older browsers may not support lookbehinds or named groups). Always double-check escapes when copying patterns to code.

What's the difference between `.*?` and `.*`?

`*` is greedy — it matches as much as possible. `.*?` is lazy (non-greedy) — it matches as little as possible. Example: on input `"bold"`, `<.*>` matches `bold` (the whole thing), while `<.*?>` matches `` (just the first tag). Use lazy quantifiers when parsing HTML/XML to avoid over-matching.

How do I match a literal dot (`.`) or other special characters?

Escape them with a backslash: `\.` matches a literal dot, `\*` matches a literal asterisk. In string literals (Python, Java, etc.), you need to double-escape: `"\."` because the string parser consumes one backslash before the regex engine sees it.

Knexio · Free browser-based tools, calculators, games, and troubleshooting guides.

About · Contact · Privacy Policy · Terms · Sitemap