Regex Tester
Test regular expressions and see all matches and groups.
Loading…
About Regex Tester
A pattern that works on three lines of sample text can fall over on real data. Enter the pattern without slashes, set the flags and paste a test string: matches are highlighted in a preview and listed one by one with their capture groups, named groups included. The page uses your browser's own JavaScript RegExp, so it behaves like regular expressions in code running in that browser. A pattern that backtracks for too long is stopped after 1.5 seconds instead of freezing the tab.
Features
- Runs your browser's own JavaScript regular expression engine
- Accepts the flags d, g, i, m, s, u, v and y
- Highlights matches inside the test string
- Lists each match with its capture groups, shown by name when the pattern names them
- Stops runaway patterns after 1.5 seconds in a background worker
- Shows empty matches together with their position
Limitations
- The test string can be up to 50,000 characters, and both the list and the highlighting stop after 500 matches.
- Only JavaScript syntax is accepted, so patterns written for PCRE, Python or .NET may need changes, and newer features such as the v flag depend on your browser.
- The tester reports matches only: there is no replace mode and no explanation of what the pattern does.
How it works
- Type the pattern into the Pattern field, leaving off the slashes at either end.
- Adjust the Flags field. It starts as i, and each flag can be used once.
- Paste the text to search into the Test string box.
- Read the match count, the highlighted preview and the numbered match list, which shows capture groups and named groups.
- Keep editing and the results refresh, or select Reset to clear everything and put the flags back to i.
Example input
\b\w+@\w+\.\w+\bFrequently asked questions
- It ran for longer than 1.5 seconds, which usually means catastrophic backtracking from nested repeats such as (a+)+. The page ends the run in its background worker so the tab stays usable. Simplify the repeats or shorten the test string.
- No. The g flag is always applied behind the scenes, so every match in the test string is listed even if the Flags field does not contain it. Repeating a flag, or typing one JavaScript does not know, produces an error message.
- Write them as (?<name>pattern) inside your expression. Each match row then shows name: value for those groups instead of a plain list, and a group that did not take part in that match reads (unset).
- No. The pattern runs in a Web Worker inside your browser, and neither the pattern nor the text is transmitted. If a worker cannot be created, the same check runs on the page itself without the timeout.
Related tools
- Javascript Escape / UnescapeEscape or unescape JavaScript strings.
- JavaScript FormatterFormat and beautify JavaScript.
- URL Encoder / DecoderPercent-encode or decode URLs and query strings.
- JSON ValidatorValidate JSON syntax and get clear error messages.
- UUID GeneratorGenerate cryptographically random UUIDs in the browser.
Related guides
- React vs. VueTwo component-based UI libraries with different philosophies on structure.
- Laravel vs. ExpressA batteries-included PHP framework vs. a minimal Node.js routing library.
- React guideA library for building user interfaces out of components.
- Vue guideAn approachable, progressive framework for building UIs.
