# Regex Tester

- **URL:** https://codeasystem.com/calculators/developer/regex-tester/
- **Category:** developer
- **Description:** Test regular expressions against sample text with live match counts, highlighted matches and capture-group breakdowns.
- **Primary output:** Matches found: 3

## Inputs
- Pattern (name: `pattern`, type: text, example: \d{3}-\d{4})
- Flags (name: `flags`, type: text, example: g)
- Test string (name: `testString`, type: textarea, example: paste the text to match against…)

## Outputs
- Matches found: 3
- Match #1 @ 1: “a”; no capture groups
- Match #2 @ 3: “a”; no capture groups
- Match #3 @ 5: “a”; no capture groups

## Formula / methodology
```
matches = testString.matchAll(new RegExp(pattern, flags)); engine-native semantics
```

Your pattern and flags build a native RegExp, so results match exactly what production JavaScript will do; including lookaheads, named groups and lazy quantifiers. Invalid patterns surface the engine’s own syntax error rather than a generic failure.

Global iteration collects every match with its index; capture groups list for the displayed matches. Duplicate flags are de-duplicated silently, analysis caps at ten thousand characters as a catastrophic-backtracking guard, and display caps at twenty rows.

## Assumptions & limitations
- JavaScript (ECMA-262) flavor; differs from PCRE/Python in escapes and lookbehind support.
- Analysis truncates beyond 10,000 characters.
- At most 500 matches iterate per run as a safety bound.

## How to use
1. **Write your pattern**; Without delimiters or slashes; just the expression itself.
2. **Set flags**; g for all matches, i for case-insensitivity, m for multiline anchors; duplicates are cleaned automatically.
3. **Inspect matches and groups**; Each row shows the matched text, its index and any capture-group contents.

## Example
Counting the vowel “a” across “banana” with global flags finds exactly three matches; the quickest possible sanity check that flags and counting behave.

Result for these inputs:

```
Matches found: 3
```

## About this calculator
### Why native-engine testing matters

Regex dialects differ subtly: JavaScript supports lookahead everywhere but lookbehind only in modern engines; POSIX classes like [[:alpha:]] fail entirely. Testing against the actual runtime regex engine eliminates the entire class of works-in-my-tool-but-not-in-prod surprises.

### Reading capture groups

- $1 is the first parenthesized group, left to right
- Non-participating groups show as empty/undefined
- Named groups (?<year>…) work and appear positionally here
- Non-capturing (?:…) groups group without consuming a slot

## FAQs
### Do I include the /slashes/ around my pattern?

No; enter just the expression. Slashes are literal characters in this context and would break matching.

### Why does my huge document get truncated?

Analysis stops at 10,000 characters to guard against catastrophic backtracking freezing your browser. The note row tells you when truncation happened.

### My pattern is valid elsewhere but rejected here?

You are probably using another flavor’s syntax (lookbehind on an old browser, possessive quantifiers, \p classes). This tool reports the exact JS engine error.

### Does it show overlapping matches?

No; JavaScript matching consumes input as it goes, so consecutive matches never overlap, mirroring real replace() behavior.

## Related calculators
- [Case Converter](https://codeasystem.com/calculators/developer/case-converter/)
- [JSON Formatter & Validator](https://codeasystem.com/calculators/developer/json-formatter-validator/)
- [MIME Type Lookup](https://codeasystem.com/calculators/developer/mime-type-lookup/)

---
Last updated: 2026-08-23 · Version: 1.0.0 · [HTML version](https://codeasystem.com/calculators/developer/regex-tester/)
