Home › Regular Expression Tester
Regular Expression Tester
Type a pattern and a test text to see exactly what matches, where, and what each capture group caught, updated as you type.
Results
- Matches
- 2
Invoices: 2025-03-14 and 2025-11-02.
| # | Position | Match | Groups |
|---|---|---|---|
| 1 | 10 | 2025-03-14 | 2025 | 03 | 14 |
| 2 | 25 | 2025-11-02 | 2025 | 11 | 02 |
How it works
The pattern is compiled by your browser’s JavaScript regular expression engine with the flags you tick, then run over the test text. Matches are highlighted in the text and listed in a table with their position and groups. A match that is empty is counted but not highlighted, and the loop always advances so a pattern like a* cannot get stuck.
Rules and details
Flags: g all matches · i ignore case · m ^ $ per line · s dot matches newline · u Unicode( ) capture group · (?<name> ) named group · (?: ) non-capturingQuantifiers: * 0 or more · + 1 or more · ? 0 or 1 · {n,m} between n and mClasses: \d digit · \w word character · \s whitespace · \b word boundary
Worked example
The pattern (\d+)-(\d+)-(\d+) on the text “Invoices: 2025-03-14 and 2025-11-02.” finds 2 matches. The first is 2025-03-14, whose groups are 2025 | 03 | 14. The second match starts at position 25, counting from zero.
Frequently asked questions
Why does only the first match appear?
Without the g flag a regular expression stops at the first match. Tick “g: find all matches” to list every one.
Are the results identical in Python, PHP or Java?
Mostly, but not always. Lookbehind support, named group syntax and Unicode behavior differ between engines, so confirm in the target language.
Can a pattern freeze the page?
A badly written pattern with nested repetition, such as (a+)+b, can take exponential time on some inputs. If the page stops responding, simplify the pattern and reload.
Tips
- Escape special characters such as . ? * + ( ) [ ] with a backslash when you mean them literally.
- Use the m flag when matching line by line with ^ and $.
- Prefer specific classes like \d+ over .* to avoid matching too much.