Regex Tester
Write a pattern, tick the flags you need, paste your text and see every match highlighted, with its position and each capture group, named groups included. Type a replacement such as $2-$1 or $<year> to preview the replaced text. An invalid pattern shows the browser's own error message instead of breaking the page. The pattern runs with your browser's JavaScript regular expression engine, and your text never leaves the page. The matching runs in a background thread that is stopped after one second, so a slow pattern cannot freeze the tab, and it is limited to 100,000 characters of text and 1,000 matches.
Checking the pattern…
How it works
- Type the pattern without the surrounding slashes, for example (\d+)-(\d+), then tick the flags you need.
- Paste or type the text to search in the test text box.
- Read the match count, the highlighted text and the table of matches with their index and groups.
- Optionally type a replacement to preview the new text, then copy it.
What people use it for
Building a pattern step by step
Add one piece at a time and watch which parts of a sample log line stay highlighted.
Extracting values
See what each group captures in a list of dates, ids or prices before putting the pattern into code.
Previewing a bulk replace
Check that $<day>/$<month>/$<year> turns 2026-11-16 into 16/11/2026 on your whole sample.
Questions
- Which regular expression flavour is it?
- The JavaScript one, the same engine as new RegExp() in your browser. Other languages (PCRE, Python, Java, .NET) differ in details such as lookbehind support, named group syntax, possessive quantifiers and flags, so a pattern that works here may need small changes elsewhere, and the other way round. Details are documented on MDN under Regular expressions.
- What do the flags do?
- g finds all matches instead of the first one. i ignores letter case. m makes ^ and $ match at each line break. s lets the dot match line breaks. u turns on Unicode mode, which reads text by code point and makes many invalid escapes errors. Flags are always applied in the order g i m s u. Without g, only the first match is listed and replaced.
- How does the replacement work?
- It is the replacement string of JavaScript's replace(): $1 to $99 insert a numbered group, $<name> inserts a named group, $& the whole match and $$ a literal dollar sign. The replacement applies to every match when g is on, and to the first one otherwise, including past the 1,000 matches the table shows. Nothing is changed in your text box: the result appears below.
- Can a pattern freeze the page, and what are the limits?
- A badly written pattern can take exponential time on some texts, which is called catastrophic backtracking, for example (a+)+$ on a long row of a followed by another character. Your browser cannot interrupt a regular expression that is already running on the page itself, so this tool runs it in a background worker instead. If the worker has not finished after 1 second, it is stopped and the page shows "Pattern too slow — stopped after 1 second"; the page stays usable and the next change you type starts a new run. The other limits are 100,000 characters of text, 500 characters of pattern and 1,000 matches in the list. In an old browser without background workers, patterns that repeat a group containing a repeat or an alternative, such as (a+)+, (a|aa)+ or (.*)*, are not run at all.