Skip to main content
Developer Tool

Regex Tester Online — Test Regular Expressions

Test a regular expression against your text as you type: matches highlighted, capture groups listed, flags toggled, with a built-in cheat sheet.

/
/g

No matches

Flags
Examples
Test Text
Insert

Enter a pattern and text to see matches

Learn more

Testing regex: the essentials

What you can check

Whether a pattern matches what you expect and nothing else: paste real samples (log lines, emails, product codes) and watch the matches, their positions and capture groups update as you edit the pattern. Toggle the g, i, m, s and u flags, and try a replacement with $1-style references before putting it in your code.

JavaScript syntax, safe to run

The engine is your browser's JavaScript one, so lookbehind, named groups and Unicode property escapes work as in Node.js and modern browsers; PCRE-only features (possessive quantifiers, recursion) don't. A pattern with catastrophic backtracking is run in a separate worker with a time limit, so it is stopped instead of freezing the tab.

Quantifiers: greedy vs lazy

By default, quantifiers are greedy — they match as much text as possible. In "<b>hello</b>", the pattern <.*> matches the whole "<b>hello</b>": .* runs to the last > of the text.

Adding ? makes a quantifier lazy — it matches as little as possible. In the same text, <.*?> matches just "<b>" (it stops at the first >), and a g search then finds "</b>" as a second match. This matters as soon as you pick pieces out of structured text like HTML or JSON.

Character classes

Built-in classes: \d matches any digit (0-9), \w matches word characters (letters, digits, underscore), \s matches whitespace (space, tab, newline). Uppercase versions (\D, \W, \S) match the opposite.

Custom classes use brackets: [a-z] matches lowercase letters, [^0-9] matches anything except digits, [A-Za-z0-9_] is equivalent to \w. Ranges work for consecutive Unicode code points.

Capture groups and backreferences

Parentheses () create capture groups that extract specific parts of a match. In the pattern (\d{4})-(\d{2})-(\d{2}), group 1 captures the year, group 2 the month, group 3 the day.

Non-capturing groups (?:...) group without capturing — useful for applying quantifiers to a group without creating an extra capture. Named groups (?<name>...) make captures more readable in code. A backreference matches the same text again: (\w+) \1 finds a doubled word such as "the the", and in a replacement $1 (or $<name>) inserts what the group captured.

Lookahead and lookbehind

Lookahead (?=...) matches a position followed by a pattern without consuming it. For example, \d+(?= dollars) matches digits only when followed by " dollars". Negative lookahead (?!...) matches when NOT followed by the pattern.

Lookbehind (?<=...) matches a position preceded by a pattern. (?<=\$)\d+ matches digits preceded by $. JavaScript supports both lookahead and lookbehind in modern engines.

How it works

Regex Tester in 3 steps

  1. Enter your regex

    Type your regular expression pattern in the input field. Turn flags on or off (g, i, m, s, u) with the chips of the toolbar.

  2. Paste your test text

    Enter the text you want to test against in the large text area. Matching portions are highlighted in real-time as you type.

  3. Review matches

    The results panel shows the number of matches, each match with its capture groups, and the start/end positions. Modify your regex to refine the results.

Practical guides

Get the most out of regex testing

How it works

Type a regular expression and a test text: matches are highlighted as you type, with their capture groups, positions and the time taken.

Test a replacement, read an explanation of each part of the pattern, and copy it as JavaScript, Python, Go, Java or PHP code. A pattern that would backtrack forever is stopped instead of freezing the page.

Quick & easy

Privacy & security

Your files and data never leave your device. All processing is done client-side in the browser.

Test texts are often real data (logs, customer emails): they never leave your browser.

Runs in your browser
Frequently asked questions

Regex Tester — FAQ

Everything you need to know about our regex tester