Development tool
Regex Tester
Test JavaScript regular expressions, inspect matching text, and review capture groups in your browser.
Result
Your result will appear here.
Highlighted matches
How to use Regex Tester
- Enter a JavaScript regular expression and flags.
- Paste test text to see matches and capturing groups.
Example
Pattern: \b[A-Z][a-z]+\b
Flags: g
Text: Hello from DevTools HubCommon use cases
- Checking a validation pattern for an ID or a short code against sample values before adding it to front-end code.
- Extracting dates, IDs, or version numbers from a log excerpt with capture groups, so you can see each part separately.
- Confirming how a pattern will match before you use it in an editor’s find-and-replace.
Input and output examples
| Input | Output | Notes |
|---|---|---|
Pattern \b[A-Z][a-z]+\b, flag g, text "Hello from DevTools Hub" | 2 matches: Hello, Hub | DevTools is skipped because there is no word boundary between v and T. |
Pattern (\d{4})-(\d{2}), flag g, text "2024-05 and 2023-11" | 2 matches; group 1: 2024, 2023; group 2: 05, 11 | Each match lists its capture groups in order. |
Common mistakes to avoid
- This is JavaScript, not PCRE or Java. Lookbehind is supported, but possessive quantifiers and atomic groups are not. A pattern copied from another language may fail here.
- The dot does not match a newline unless the s flag is set. The anchors ^ and $ match only the start and end of the whole text unless the m flag is set.
- In code, a backslash inside a string literal is an escape character. The pattern \b in a string must be written \\b, but this field takes the raw pattern as typed.
Technical details
The tool uses the JavaScript RegExp engine, whose syntax is defined in ECMA-262 (the ECMAScript Language Specification). The flags are passed to the RegExp constructor. Without the g flag only the first match is listed. Test text is limited to 200,000 characters. Patterns with nested quantifiers can take a very long time on some inputs, which is called catastrophic backtracking.
Frequently asked questions
Does this use PCRE?
No. It uses the JavaScript regular expression engine and its supported flags. PCRE features such as possessive quantifiers are not available.
Why is only one match shown?
Without the g flag the engine returns only the first match. Add g to list every match.
What do the flags mean?
g finds all matches, i ignores case, m makes ^ and $ match at each line, s lets . match a newline, u enables Unicode mode, and y matches only at the last index. The flag field accepts up to 8 characters, and an invalid flag is reported as an error.
Why did the page slow down with my pattern?
The pattern probably backtracks heavily. Nested quantifiers such as (a+)+ are a common cause. Shorten the test text or simplify the pattern.
Is my test text uploaded?
No. Matching runs in your browser, and the tool code does not send the text to a server.
Why was my text rejected?
The tool accepts up to 200,000 characters of test text. Split a longer sample into smaller pieces.