Free Regex Tester

Test JavaScript regular expressions instantly in your browser. Enter a pattern, add flags like g for global or i for case-insensitive, and see all matches highlighted with counts. Perfect for debugging regex before you use it in code.

3 matches

  • 12
  • 3
  • 45

Uses the JavaScript regular-expression engine, in your browser. Flags: g (global), i (ignore case), m (multiline), s (dotall), u, y.

Quick answer

A regex tester lets you write a pattern and see what it matches in real text, showing each match and the total count. Use it to debug patterns before using them in code—test whether your pattern finds what you expect without guessing.

Formula & method

Enter a JavaScript regular expression pattern (like /\\d+/ or [A-Z]+) and optional flags (g for global, i for case-insensitive, m for multiline, etc.). Paste or type the text you want to test. The tool will instantly show every match found, the matched text for each, and the total count of matches. Results update as you type.

Examples

Example 1: Find all numbers
Input
Pattern: /\d+/g | Text: a12b3
Result
Matches: 12, 3 | Count: 2
Why
The \d matches digits, + means one or more, and the g flag finds all matches in the string instead of stopping at the first.
Example 2: Case-insensitive word match
Input
Pattern: /hello/i | Text: Hello there
Result
Matches: Hello | Count: 1
Why
The i flag makes the pattern ignore case, so 'hello' (lowercase) matches 'Hello' (capitalized). Without the i flag, this would find zero matches.
Example 3: Find 5-letter words
Input
Pattern: /\b\w{5}\b/g | Text: The quick brown fox
Result
Matches: quick, brown | Count: 2
Why
\b marks word boundaries, \w matches word characters, and {5} means exactly 5 of them. This finds words that are exactly 5 letters long.

When to use this tool

  • Before using a regex in your JavaScript code to make sure it matches the text you expect
  • When learning regex to experiment and see instantly how different patterns and flags change what gets matched
  • To validate user input patterns or search strings without having to write and run code

Common mistakes

  • Forgetting the global flag (g) when you want to find all matches instead of just the first one
  • Using double backslashes (\\) in the pattern field when you only need single backslashes (\) — the tool interprets them as regex escape sequences, not string escapes
  • Assuming character classes like [a-z] match whole words — they match individual characters only

Frequently asked questions

What flags can I use?

JavaScript regex supports: g (global - find all matches), i (case-insensitive), m (multiline - ^ and $ match line starts/ends), s (dotAll - . matches newlines), u (Unicode), and y (sticky). You can combine them like /pattern/gim.

Is my data uploaded or stored?

No. Everything runs in your browser. Your regex patterns and test strings never leave your device.

What's the difference between test and match?

This tool shows matches (the actual text that was found). A 'test' would just return true/false. This tool is more useful for seeing exactly what was matched.

Can I match newlines?

Yes. Use \n to match a newline, or add the m flag so that ^ and $ match line boundaries instead of just the string boundaries. Use the s flag to make . match newlines too.

Why is my pattern not matching anything?

Common reasons: forgetting to escape special characters (use \. to match a literal dot, \+ for a literal plus), wrong flags (add i for case-insensitive), or character class mistakes ([a-z] matches one letter, not a whole word).

Can I use lookahead or lookaround?

Yes. JavaScript regex supports positive lookahead (?=...), negative lookahead (?!...), positive lookbehind (?<=...), and negative lookbehind (?<!...).

Sources & references

External references open in a new tab. We are independent and not affiliated with these organizations.

  • ✓ Free to use
  • ✓ No sign-up required
  • Runs entirely in your browser — nothing is uploaded.
  • ✓ Formula and method shown above

Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.

Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.

Related tools

Embed this tool on your site

Free to embed, no sign-up. Paste this code where you want the regex tester to appear: