What this tool does
Regex Tester uses new RegExp(pattern, flags) to compile expressions without eval. The matching work is placed in the Web Worker; if it exceeds about 750 milliseconds, the Worker will be terminated and a prompt will be displayed that it takes too long to avoid a catastrophic backtracking expression that occupies the main page for a long time.
- Supports six JavaScript flags: g, i, m, s, u, y.
- The results list the matching text, starting index, numbered capture group, and named capture group.
- Highlighting is constructed from text nodes and mark elements, without splicing user HTML.
How to use it
- Enter Pattern without the / on both sides.
- Select the required flags.
- Paste the Test String and click "Test Regex".
- View match count, index, capturing groups, and highlighting.
Common uses
- Debug logs, filename and form validation modes.
- Compare global and non-global matching behavior.
- Observe the capture groups and case, multiline, dotAll options.
Regex Tester Features
Test flags, match indexes and capture groups, and use timed workers to isolate high-risk expressions. It is suitable for daily development, debugging, data sorting and code optimization scenarios. The processing results can be directly viewed, copied or downloaded.
FAQ
Why doesn't Pattern write /.../?
The input box only receives the expression body, and flags has an independent checkbox to avoid confusion between slashes and slashes in the content.
What is catastrophic backtracking?
Certain nested quantifiers cause the engine to try exponential combinations. The tool can use worker termination and timeout to reduce the risk of the main page getting stuck.
How many matches will be displayed if g is not checked?
According to JavaScript regular semantics, only the first match is returned; after g is checked, all matches will continue to be enumerated.