# Regex Tester

> Test JavaScript regex patterns against sample text with real-time match highlighting. See every match, its index and capture groups, with g, i, m and s flags.

- Open the tool: https://overtooled.com/regex-tester
- Category: Developer
- Privacy: Runs entirely in your browser. Nothing is uploaded, no account is needed, and it works offline once loaded.
- Price: free, no sign-up
- Keywords: regex, regular expression, pattern, match, test

## In short

Test regex patterns with real-time match highlighting.

## Overview

Tests a JavaScript regular expression against sample text with live match highlighting, a match list, and capture group values. Matching runs in a Web Worker with a 2-second timeout so catastrophic backtracking cannot freeze the page. For developers writing or debugging JS regex patterns.

## Features

- Uses the browser's native JavaScript (ECMAScript) RegExp engine
- Flag toggles: g (global), i (case insensitive), m (multiline), s (dotAll); g is on by default
- Live results, debounced by 150 ms after each change
- Pattern syntax errors are shown immediately with the RegExp error message
- Highlighted view of the test string with every match marked (only the first match without the g flag, as in JavaScript)
- Match list with match number, matched text, start index, and positional capture group values; tap a match to copy its text, and the Pipeline button above the list sends the match tapped last (the first until then)
- Match count shown next to the Matches heading, and "No matches." when the pattern matches nothing
- Collection stops after 5,000 matches (shown as "5,000+", with only those highlighted) and the list shows the first 500, so a pattern like . on a large text cannot freeze the page
- Execution runs in a Web Worker; if it takes over 2 seconds the worker is killed and a "Pattern timed out (possible catastrophic backtracking)" error is shown

## How to use it

1. Type a pattern (without surrounding slashes) in the Pattern box
2. Toggle flags as needed
3. Type or paste text into Test String
4. Review the highlighted text and the match list

## Inputs

- Pattern: JavaScript regex source, entered without delimiters
- Flags: any combination of g, i, m, s
- Test string: any text

## Outputs

- Test string with matches highlighted (rendered as plain text, never as markup)
- List of matches with index and capture groups; copy any single match value

## Limits and notes

- Only g, i, m, and s flags can be toggled; u, v, y, and d are not available
- Named groups are listed by position only, not by name; group indices are not shown
- No replace/substitution mode and no "copy all matches" action
- Clear button (shown when a pattern is entered) clears both the pattern and the test string
- Requires Web Worker support; nothing is saved to localStorage and nothing is uploaded

## Questions and answers

### How does the Regex Tester work?

Your pattern is first compiled with new RegExp(pattern, flags) to catch syntax errors instantly. Matching then runs in a Web Worker using a RegExp.exec() loop, so a slow pattern cannot freeze the page; if it takes longer than 2 seconds the worker is stopped and a timeout error is shown. Matches are highlighted in the test text and listed with their start index and capture group values. You can toggle the g, i, m, and s flags.

### What regex flavor does this use?

It uses JavaScript's built-in RegExp engine, which supports features like lookahead, lookbehind, named capture groups, and Unicode property escapes. This is the same regex engine used in Node.js and all major browsers.

### What are regex flags like g, i, and m?

The "g" flag finds all matches (not just the first), "i" makes the pattern case-insensitive, and "m" makes ^ and $ match the start and end of each line instead of the entire string. You can toggle these in the flags panel.

### How do I see capture groups?

Parentheses in your pattern create capture groups. Each match in the list shows its groups' values in order, as groups: ["...", "..."]. Named groups (?<name>...) work in the pattern but are listed by position, not by name.

## Related tools

- [Mock Data Generator](https://overtooled.com/mock-data-generator.md): Generate realistic fake data for testing, prototyping, and demos
- [Barcode Generator](https://overtooled.com/barcode-generator.md): Generate single or bulk barcodes (EAN-13, UPC-A, Code 128, Code 39). Download as PNG or ZIP.
- [Base64 Encode/Decode](https://overtooled.com/base64.md): Encode text to Base64 or decode Base64 strings instantly
- [Chart Studio](https://overtooled.com/chart-studio.md): Create beautiful bar, line, pie, and scatter charts from your data

---
Overtooled: 179 free tools that run in your browser. Index of all tools: https://overtooled.com/llms.txt
