How to test a regular expression
- Type your pattern into the Regular expression box, without the surrounding slashes. A sample pattern that finds email addresses is loaded to start with.
- Choose flags by tapping g, i, m, s, u or y. The active flags are shown after the closing slash.
- Paste your test text. Every match is highlighted in the box on the right, with a count above it.
- Optionally add a replacement, such as
$1or$<name>, to preview the text after replacing. - Check the match details table for the position of each match and the value of every capture group.
Features
- Live highlighting of matches as you type.
- All six JavaScript flags: global, ignore case, multiline, dot-all, Unicode and sticky.
- Capture groups in a table, with named groups shown under their own names.
- Replace preview supporting
$1,$<name>and$&, with a copy button. - Match count and positions, with the first 1,000 matches listed.
- Protection against runaway patterns: evaluation runs in a Web Worker and is stopped after 1.5 seconds.
- Clear error messages from the engine when a pattern is invalid, such as an unclosed group.
Why use Fileora's regex tester
Test data is often real data: server logs, customer exports, email lists. Fileora runs the regular expression in your browser, so none of it leaves your device. It is free, has no sign-up, and the flag buttons are large enough to use comfortably on a phone.
Because the tester uses the same engine as your JavaScript code, there are no surprises when you copy the pattern into your project.
JavaScript regex cheat sheet
.any character except a line break (any character at all with the s flag)\d,\w,\sa digit, a word character (letter, digit or underscore), a whitespace character\D,\W,\Sthe opposite of each of the above[abc],[^abc],[a-z]one character from a set, not in a set, or in a range^and$start and end of the text, or of each line with the m flag\ba word boundary*,+,?zero or more, one or more, zero or one{3},{2,5}exactly 3 times, or between 2 and 5 times*?,+?lazy versions that match as little as possible(abc)a capture group;(?:abc)a group that doesn't capture(?<year>\d{4})a named group, used as$<year>in a replacementa|beither a or b(?=x),(?!x)followed by x, not followed by x(?<=x),(?<!x)preceded by x, not preceded by x\p{L}any letter in any script, with the u flag, useful for Urdu and Hindi text
Avoiding slow patterns
Catastrophic backtracking usually comes from a repeated group that contains another repeat, like (a+)+ or (\w+\s?)*. Make each part match something distinct, anchor the pattern with ^ and $ where possible, and prefer specific character classes over .*.
To check the effect of a replacement on a long file, compare before and after in the diff checker, and tidy up extracted JSON with the JSON formatter.