Online regex tester (JavaScript)
Type a regular expression and some text to see every match, its groups and its position, with a plain-English explanation of the pattern. Free, and nothing leaves your browser.
Free, no sign-up, no limit Runs in your browser: your text and files are never sent or saved.
Regex tester
The test runs in your browser, in a separate thread stopped after 1 second.
How to use it
- Type the pattern (or paste /pattern/flags) and tick the flags you need.
- Paste the test text: matches are highlighted and listed with their groups.
- Optionally type a replacement ($1, $<name>, $&) to preview the result.
Example
Input
Pattern: (?<user>[\w.+-]+)@(?<domain>[\w-]+\.[\w.-]+) Flags: g Text: Contact anna@example.com or ben.lee@mail.example.org for access.
Output
anna@example.com ben.lee@mail.example.org
Good to know
- The browser’s JavaScript engine is used: syntax specific to PCRE, Python or .NET (possessive quantifiers, (?i) inline flags, \A, \Z) may be rejected or behave differently.
- A pattern that runs for more than one second is stopped, to protect the page from catastrophic backtracking.
- At most 1,000 matches are listed.
- The explanation covers common tokens; it is a reading aid, not a full parser.
- Pattern and text stay in your browser: nothing is sent to a server.
Frequently asked questions
How do I test a regex online?
Type the pattern without slashes, or paste /pattern/flags, then paste the text to search. Matches are highlighted as you type and listed with their position and groups, and the pattern is explained piece by piece below. Add a replacement to preview a search and replace.
Which regex flavor does this tester use?
Your browser’s JavaScript engine (ECMAScript), so the result is exactly what your JS or TypeScript code will do. Most syntax is shared with Python, PHP (PCRE), Java and C#, but inline flags like (?i), possessive quantifiers or \A and \Z may be rejected or behave differently.
How do I use capture groups in a replacement?
Write $1, $2… for numbered groups, $<name> for a named group (?<name>…) and $& for the whole match. For example, (\d{4})-(\d{2}) replaced with $2/$1 turns 2024-05 into 05/2024. Python writes the same references as \1 and \g<name>.
What do the regex flags g, i, m, s, u and y mean?
g finds all matches instead of the first; i ignores case; m makes ^ and $ match at each line; s lets the dot match line breaks; u enables full Unicode, including \p{L} and emoji; y (sticky) only matches from the current position, here 0.
Why does my regex freeze or get stopped?
Nested quantifiers such as (a+)+$ can try billions of combinations on a text that almost matches: this is catastrophic backtracking. The tester stops any search after 1 second. Make quantifiers more specific, for example [^,]* instead of .*, to fix it.
How do I test a regex in Python or C#?
In Python: re.search(r"pattern", text) or re.findall for every match. In C#: Regex.IsMatch(text, @"pattern") or Regex.Matches. Simple patterns behave the same as here; check engine-specific syntax such as lookbehind or named groups in that language’s documentation.