A regular expression describes a pattern to find in text. This tester uses your browser's JavaScript regex engine and displays the matching text, zero-based positions and capture groups. It is useful for checking a validation idea, extracting repeated identifiers or understanding why a pattern matches too much. Try representative samples, including cases that should fail. A pattern that works on one short sentence may behave differently on line breaks, empty values or long strings. The tool runs matching in a separate worker so an expensive pattern can be stopped.
Step by step
How to use Regex Tester
Enter the pattern without the surrounding slash delimiters used in JavaScript source code. For example, enter \d+ to find one or more digits, then put any flags in the separate Flags field. Do not paste a complete JavaScript assignment or call.
Choose flags intentionally. The g flag finds repeated matches; without it the result stops at the first match. The i flag ignores letter case, m changes line-boundary behaviour, and s lets a dot match line breaks. Unicode-related flags depend on browser support.
Paste a test string containing both expected matches and near misses. Include punctuation, spaces or line breaks that occur in real input. Keep the test text under 200,000 characters and the pattern under 10,000 characters so the browser can handle the test promptly.
Run the expression and inspect the match list. Compare the highlighted meaning in your head with the actual matched text and groups, then change one part of the pattern at a time. Download the JSON result if you need a record. Test invalid and empty input before adopting the pattern in code.
Practical tasks
Options and tips for Regex Tester
Positions, groups and empty matches
Match positions use JavaScript UTF-16 offsets, starting at zero. Some visible characters, including many emoji, occupy two code units, so a position is not always the same as a count of visible symbols. Parentheses can capture parts of a match; named capture groups make the result easier to interpret. Patterns can also match an empty string, such as an optional element or a boundary. The tester reports these matches explicitly and advances the search to avoid an endless loop. It stops after one thousand results to keep the page manageable.
Testing performance and portability
Nested repetition can make a regex take unexpectedly long on text that almost matches. A classic problem is repeated groups followed by a failing final character. The tester terminates its worker after about one and a half seconds, allowing you to simplify the expression and try again. That timeout does not prove a pattern is safe for every production input. Also check the runtime where the pattern will actually run: JavaScript, Python and server-side regex engines differ in supported constructs, flags and escaping. This page tests matching; it does not apply replacement expressions.
A little help
Frequently asked questions
Why do I get only one match?
The global g flag is required to collect repeated JavaScript matches. Without it, the tester intentionally reports the first match. Add g when you want a list, then check whether your pattern can also produce empty matches.
Why is a valid pattern rejected in an older browser?
New JavaScript regex features arrive at different times across browsers. Try a current browser and check support in your target environment. A feature accepted here may still fail in an older production runtime.
What does the timeout message mean?
The matching worker exceeded the allowed time. Reduce input size, remove ambiguous nested repetition or add clearer boundaries. Do not simply assume the pattern has no matches; the test did not finish.
Does this validate all email addresses or phone numbers?
Only the pattern you provide determines what matches. Real address and phone rules involve context that a simple pattern may omit. Test the specific format your application accepts and use appropriate dedicated validation where necessary.
Your next step