Your everyday developer toolkit

Regex Tester

Test JavaScript regular expressions against text in your browser.

Patterns run in a separate worker and stop after one second. At most 100 matches are displayed.

Processed in your browser; input is not sent to the server.

A practical guide to regular expressions

What is a regular expression?

A regular expression, often called a regex, is a pattern for finding text. A pattern can describe literal characters, character classes, repetition and boundaries. JavaScript provides the RegExp engine used by this tester. For example, \d+ matches one or more digits, while ^ and $ can anchor a match to the beginning or end of a line or input.

Regex dialects differ. A pattern accepted by JavaScript may behave differently in Python, a database, or a command-line tool. This page accepts the pattern without surrounding slash delimiters and a separate flags field. The g flag finds multiple matches; i ignores case; and m changes the behavior of line anchors. Supported flags depend on your browser.

Common developer uses

Developers use regular expressions to search logs, extract simple identifiers, validate narrowly defined inputs and transform text. They are also helpful when exploring unfamiliar data before writing a parser. For complicated formats such as nested JSON, use a proper parser rather than trying to describe the entire grammar with a regex.

Enter a pattern, flags and sample text. Results update locally and show the match index, matched text and captured groups. Indices follow JavaScript's UTF-16 string indexing, which may differ from the number of visible characters. Results are capped at 100 matches. An empty pattern leaves the result blank to avoid surprising output while you edit.

Troubleshooting errors

If the tester reports an invalid expression, check for an unclosed parenthesis or character class, invalid escapes and duplicate or unsupported flags. Do not include slash delimiters around the pattern. If a match is missing, inspect anchors and whitespace, and try a smaller portion of the pattern. Test examples that should match and examples that should not.

Greedy quantifiers can consume more text than expected. For instance, a broad repeated wildcard may span several delimiters; use a narrower character class or a non-greedy quantifier when appropriate. Remember that a regex can match an empty string. This tester advances safely after empty matches so a global search does not loop forever.

Performance and privacy

Some patterns exhibit catastrophic backtracking and can take a very long time on certain inputs. This tool runs matching in a separate browser worker and stops it after one second; a timeout is not proof that a pattern is safe elsewhere. Keep expressions simple and impose limits in production. Input stays in your browser, but browser extensions, shared devices and copied results remain part of your privacy boundary.