Regex tester and line filter
Check a pattern before putting it in code, or use it as a tool: pull matching lines out of a log, drop lines from a list, or preview a find-and-replace on pasted text.
Runs in your browser. Nothing is uploaded.
Loading tool…
How to use
- Type a pattern and tick the flags.
- Paste the text to test.
- Choose Matches, Keep or Remove matching lines, or Replace.
Common uses
- Check a validation pattern for emails, postcodes or order numbers before putting it in code.
- Pull only the error lines out of a long log file.
- Reformat dates or names in a list with a find-and-replace using captured groups.
Example
- Input
- Pattern (?<y>\d{4})-(\d{2}) on “2024-01 and 2025-12”
- Result
- #1 at 0: 2024-01 ($1 = "01", y = "2024") · #2 at 12: 2025-12
Good to know
- Engine: JavaScript, so results match JavaScript and TypeScript code. Python, PHP and others differ in places.
- Matches: every match with its position and groups, up to 10,000.
- Keep or Remove lines: each line is tested on its own.
- Flags: g finds every match, i ignores capitals, m makes ^ and $ work on each line, s lets the dot match line breaks, u turns on full Unicode support.
- Replace: without the g flag only the first match changes. Use $1, $<name> or $& to insert what was matched.
- Frozen tab: some patterns, such as (a+)+$, can run for a very long time on long text. Reload the page if that happens.
- Text stays in your browser tab and is not saved.
Questions
Do I type the slashes?
No. Type the pattern only, such as \d+, and use the checkboxes for flags.
Why does my pattern work here but not in Python or PHP?
Regex dialects differ. This tester uses JavaScript's engine; check your language's documentation for features such as lookbehind or named groups.
What does the g flag change?
Matches always lists every match. For Replace, g replaces all matches; without it only the first is replaced.