Skip to main content

Regex Tester

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

/ /
Matches: 0
Match
edit_note By Meet Dhameliya
update Updated: Jul 28, 2026
schedule 5 min read

Regular expressions are one of the most powerful tools in a developer's arsenal — and one of the most difficult to write correctly on the first attempt. A pattern that looks right in your head fails on edge cases you didn't consider. A working regex from Stack Overflow does exactly what it says it does, but not quite what you need it to do. An email validation regex that passes review but silently rejects valid addresses with plus signs. The only reliable way to develop a regex is to test it interactively against real-world sample data as you build it, seeing exactly which substrings match, which don't, and what each capture group extracts. The Utility Spark Regex Tester uses JavaScript's native RegExp engine to evaluate your pattern against your test text in real time. As you type the pattern, all matches highlight in the text. Capture groups are extracted and displayed separately. Flags (g for global, i for case-insensitive, m for multiline, s for dotall) are supported. Everything runs client-side — your pattern and test data never leave your browser.

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

Every match in the test text is highlighted the instant you stop typing the pattern — no button click required. The highlight updates with each keystroke, letting you see immediately how a pattern change affects the set of matches. Adding a character class, changing a quantifier, or anchoring the pattern all produce instant visual feedback.

Capture Group Extraction

Named and numbered capture groups are extracted and displayed separately from the full match. For example, a pattern like (\d{4})-(\d{2})-(\d{2}) on '2024-07-28' extracts group 1 = '2024', group 2 = '07', group 3 = '28'. This is essential for understanding what your regex extracts from complex string patterns before writing the surrounding code.

Flag Support — g, i, m, s

Toggle regex flags with checkboxes: g (global, find all matches not just the first), i (case-insensitive), m (multiline, ^ and $ match line starts/ends not just string start/end), s (dotAll, make . match newline characters). Each flag produces immediately visible changes to the match set.

Match Count and Position Display

Displays the total number of matches found and, for each match, its start and end index position in the test string. This is useful when writing code that uses match positions to extract substrings or apply transformations.

JavaScript Engine — Matches Your Browser/Node.js Behaviour

The tool uses the same JavaScript RegExp engine your browser uses and that Node.js runs. If a pattern works here, it will behave identically in your JavaScript/TypeScript code. Other regex tools may use PCRE or Python's re module, which have different syntax and behaviour for features like lookaheads, lookbehinds, and unicode handling.

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

Pattern: ^[6-9]\d{9}$
Flags: m (multiline for testing multiple numbers)
Test text: 9876543210, 8765432109, 1234567890, 6000012345
Matches: 9876543210 ✓, 8765432109 ✓, 1234567890 ✗ (starts with 1), 6000012345 ✓
Explanation: ^[6-9] requires start with 6-9, \d{9} requires exactly 9 more digits

science Extracting Dates from Text

Pattern: (\d{4})-(\d{2})-(\d{2})
Flags: g (global — find all)
Test: 'Invoice dated 2024-07-15, due 2024-08-15, filed 2025-01-01'
Matches: 3 matches | Group 1: year, Group 2: month, Group 3: day extracted from each date

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 (?<name>pattern) syntax: (?<year>\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