Regular Expression Tester
Test a JavaScript regular expression, flags and capture groups entirely in the browser.
Result
| # | Match | Index | Capture groups |
|---|---|---|---|
| 1 | 192.168.1.1 | 8 | 1: 192 |
| 2 | 10.0.0.254 | 42 | 1: 10 |
About Regular Expression Tester
Compile and run JavaScript regular expressions locally, with match offsets and capture-group output. The tester adds global matching internally so repeated matches can be listed without altering the requested flags.
Engine compatibility
The browser JavaScript engine defines supported syntax, Unicode behaviour and capture semantics. A pattern copied from PCRE, RE2 or .NET may need changes even when it looks similar.
Designing reliable patterns
Prefer explicit boundaries and constrained character classes over broad wildcards. Test valid, invalid and adversarial samples, including empty strings and very long lines. A regex that extracts an address does not prove the address is valid; follow matching with domain validation. For untrusted large input, avoid nested ambiguous repetition because backtracking can consume significant CPU and make an otherwise simple browser tool or production service unresponsive.
Common use cases
- Extract addresses or identifiers from logs.
- Verify capture groups before writing a parser.
- Test case sensitivity and multiline behaviour.
Edge cases and gotchas
- JavaScript regex syntax differs from PCRE, RE2 and .NET.
- Catastrophic backtracking can freeze a browser tab; avoid ambiguous nested quantifiers on large input.
- Benchmark the final pattern with realistic and adversarial data in the target runtime. Browser success does not establish acceptable latency or denial-of-service resistance in a production parser.