Regex Tester

Test regular expressions against text data with real-time highlighting.

/ /
Matches: 0
Match
fact_check Reviewed by Senior Editor
verified Reviewed: Jul 28, 2026
update Updated: Jul 28, 2026
commit v2.0.0
schedule 5 min read

lightbulb When to use this tool

  • check_circle Building and testing an input validation pattern (email, phone number, postcode, PAN card, GST number) before implementing it in production code.
  • check_circle Debugging a regex that works in most cases but fails on specific edge cases — paste a failing example and watch what matches.
  • check_circle Testing a find-and-replace pattern before running it on a large file in VS Code or a deployment script.
  • check_circle Learning regex syntax by experimenting with patterns and seeing their effects immediately.
  • check_circle Verifying that a third-party regex from documentation or Stack Overflow matches your specific data format.

Why use our tool?

Real-Time Match Highlighting as You Type

Capture Group Extraction

Flag Support — g, i, m, s

Match Count and Position Display

JavaScript Engine — Matches Your Browser/Node.js Behaviour

How it works

1

Enter your regular expression pattern in the Pattern field (without the surrounding / delimiters).

2

Set any required flags using the flag toggle buttons: g (global), i (case-insensitive), m (multiline), s (dotAll).

3

Paste your test text in the Test String area.

4

All matches highlight in yellow/colour in real time. Scroll through the text to see all matches.

5

Below the test area, view each match's full text, index position, and any extracted capture group values.

Examples

science Validating Indian Mobile Numbers

science Extracting Dates from Text

Frequently Asked Questions

Which regex engine does this tool use? expand_more
The tool uses JavaScript's built-in RegExp engine — the same engine used by Chrome (V8), Firefox (SpiderMonkey), Safari (JavaScriptCore), and Node.js (V8). Patterns tested here will behave identically in your JavaScript and TypeScript code. Note that JavaScript's regex engine differs from PCRE (used by PHP, Python's re module, many text editors) in some advanced features — particularly in lookbehind assertion syntax and certain Unicode property escape behaviours.
What are capture groups and how do I use them? expand_more
Capture groups are parenthesised portions of a regex pattern: (\d+) captures one or more digits. When a match is found, each group's matched text is extracted separately from the full match. In JavaScript: 'hello world'.match(/(\w+)\s(\w+)/) returns ['hello world', 'hello', 'world'] where index 1 and 2 are the group captures. Named groups use (?pattern) syntax: (?\d{4}) captures to a group named 'year', accessible as match.groups.year in JavaScript.
What does the 'g' flag do? expand_more
The global flag (g) tells the regex engine to find all non-overlapping matches in the test string rather than stopping after the first match. Without 'g', a pattern only matches once even if the string contains multiple occurrences. For most real-world use cases — finding all occurrences of a pattern, replace-all operations, match iteration — the 'g' flag is required.
How do I test a multiline pattern? expand_more
Use the m (multiline) flag. Without it, ^ matches only the very start of the string and $ matches only the very end. With m, ^ matches the start of each line and $ matches the end of each line. Paste your multi-line test text and the pattern with ^ and $ anchors will match at each line boundary.
What is a lookahead and how do I use it in this tester? expand_more
Lookaheads are zero-width assertions that check what comes after (or before with lookbehind) the current position without consuming characters. Positive lookahead (?=...) matches if followed by the pattern. Negative lookahead (?!...) matches if NOT followed by the pattern. Example: \d+(?= dollars) matches a number only when followed by ' dollars'. The JavaScript regex engine supports positive and negative lookaheads, and ES2018+ introduced positive and negative lookbehinds (?<=...) and (?
My regex works in the tester but not in my code — why? expand_more
The most common reasons: (1) Missing the global 'g' flag in your code — String.match() without 'g' returns only the first match. (2) Escaping differences — in a JavaScript string, you need double backslashes (\\d instead of \d) unless using a regex literal (/\d/). (3) The 's' dotAll flag is needed if your pattern uses '.' to match newlines but you didn't enable it. (4) You're using a method that behaves differently — replace() vs replaceAll(), exec() in a loop vs matchAll(). Check your code matches the flags you tested here.

More Developer & Security