Regex Tester
Test JavaScript regular expressions with g, i, and m flags, live match highlighting, and capture group inspection locally in your browser.
About this tool
Every input change compiles new RegExp(pattern, flags) inside a try/catch block, collects matches with a safe loop guard, updates Matches and capture group KPIs, and paints highlighted spans using DocumentFragment text nodes. Test form validation and URL parsing patterns quickly.
How to use the regex tester
- Type a regular expression in the pattern box. Matches are highlighted in the test text as you type.
- Tick the flags you need: g (global) finds every match, i ignores upper and lower case, and m makes ^ and $ match at each line.
- Edit the test string to check edge cases, such as an empty line or a value with a symbol in it.
- Read the Valid pattern status, and copy the matches once the pattern works.
What regular expressions do
A regular expression describes a pattern of text. \d+ matches one or more digits, [A-Z] matches one capital letter, and (order-\d+) matches the word order- followed by digits and remembers them as a group. They are used to search, validate and extract text in logs, forms, code and data files.
Patterns can be simple or very complex, and a small change can match far more than you intended. Testing against realistic sample text, including lines that should not match, is the best way to catch those surprises.
A worked example
The sample log holds dates, levels and identifiers. The pattern (order|invoice|payment)-\d+ highlights order-104, invoice-209 and payment-330 with the g flag. Adding the i flag would also match Order-104 in capitals. An email pattern such as [\w.]+@[\w.]+ picks out the two addresses in the log, which is the kind of check you can run before you write a parser.
- Find every order number in a day's log to check which orders shipped.
- Test a pattern that validates a postcode before adding it to a form.
Who uses a regex tester
- Developers writing search filters, validation rules and log parsers.
- Support staff searching logs for error codes and identifiers.
- Data analysts cleaning text fields before a report.
- Students learning pattern matching.
- Editors finding and checking formats such as dates and reference numbers.
Tips and common mistakes
- Escape special characters such as . ? + ( ) with a backslash when you want them to match literally.
- Greedy patterns such as .* can match more than you expect. Use .*? when you need the shortest match.
- Each regex engine has small differences. This tester uses the JavaScript engine, which may differ from Python or PCRE.
- Patterns with nested repeats can run very slowly on long text. Keep the test text short while you refine a pattern.
- The pattern and the test text stay in your browser. Nothing is sent to our server.
Frequently asked questions
Related browser tools
Base64 Encoder / Decoder
Encode and decode Base64 strings with full UTF-8 and URL-safe (Base64URL) support locally in your browser with zero uploads.
CSV to JSON Converter
Convert CSV, TSV, and semicolon-delimited tables into clean JSON arrays locally in your browser with quoted-comma support and zero uploads.
Hash Generator
Compute SHA-1, SHA-256, SHA-384, and SHA-512 cryptographic digests simultaneously locally in your browser using Web Crypto with zero uploads.