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
Enter your regular expression pattern in the Pattern field (without the surrounding / delimiters).
Set any required flags using the flag toggle buttons: g (global), i (case-insensitive), m (multiline), s (dotAll).
Paste your test text in the Test String area.
All matches highlight in yellow/colour in real time. Scroll through the text to see all matches.
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
What are capture groups and how do I use them? expand_more
What does the 'g' flag do? expand_more
How do I test a multiline pattern? expand_more
What is a lookahead and how do I use it in this tester? expand_more
My regex works in the tester but not in my code — why? expand_more
More Developer & Security
CSV to JSON Converter
Convert tabular CSV data into structured JSON format instantly and completely client-side.
Text Compare (Diff Checker)
Compare two text documents to find differences and similarities with highlighted inline diffs.
JSON Formatter & Validator
Beautify, validate, and minify JSON data with exact syntax error detection and tree-view visualization.
Find & Replace
Batch process text documents with advanced string matching. Supports basic regex patterns.