Text & Regex

Regex Tester

Test regular expressions online with highlights, capture groups, and a replacement preview.

Flags

Patterns run on the browser's built-in JavaScript regex engine.

Test text0 characters · 0 lines
4 ready-made examples · Ctrl+Enter to test

Regex results

Enter a pattern to test a regular expression

Add a pattern, choose flags, and paste test text. Matches, capture groups, and the replacement preview update as you type.

Enter a regular expression pattern to begin.

Your data stays private

This tool runs directly in your browser. The content you enter is processed locally and is not sent to TechFixGen servers. No account or signup is required.

Regex Tester, explained

What is a regular expression?

A regular expression (regex) is a compact pattern that describes text. You use it to find, validate, and transform strings — checking that input looks like an email address, pulling numbers out of a log line, or renaming fields in bulk.

A pattern is built from literal characters plus metacharacters such as ., *, and \d, and is applied with a set of flags that change how matching behaves.

How to test regex

  1. Type or paste the pattern into the pattern field.
  2. Toggle the flags you need — g to find every match.
  3. Paste representative test text below the flags.
  4. Review the match count, highlighted preview, and match list.
  5. Expand each match to inspect numbered and named capture groups.
  6. Optionally enter a replacement to preview the result before using it.

Common flags

  • g — global

    Find every match, not just the first.

  • i — ignore case

    Match letters regardless of upper or lower case.

  • m — multiline

    Make ^ and $ match at the start and end of each line.

  • s — dotAll

    Allow . to match newline characters.

  • u — unicode

    Treat the pattern as Unicode code points (needed for \u{...} and some emoji).

  • y — sticky

    Match only at the current lastIndex position.

Capture groups

Parentheses ( … ) capture part of a match so you can refer to it. Groups are numbered by their opening parenthesis, starting at 1. In the pattern (\d4)-(\d2), the year is group 1 and the month is group 2.

A group that is optional and absent reports did not participate. Use a non-capturing group (?: … ) when you only need to group tokens without creating a numbered capture.

Named groups

A named group uses the syntax (?<year>\d{4}) and can be referenced by name instead of number. Named groups are shown separately in the match list, so the pattern stays readable as it grows.

Regex replacement

The replacement field previews what a JavaScript String.prototype.replace call would produce. The replacement string supports $& for the whole match, $1, $2… for numbered groups, and $<name> for named groups. Without the g flag, only the first match is replaced.

JavaScript regex note

This tester runs your pattern on the browser's native JavaScript RegExp engine. That is the same engine your JavaScript uses, but it is not PCRE, Python, .NET, Java, or RE2. Lookahead is supported in modern browsers; lookbehind depends on the browser's engine version.

Cheat sheet

  • .Any character except a line break (unless the s flag is on).
  • \dA digit (0–9).
  • \wA word character (letter, digit, or underscore).
  • \sA whitespace character (space, tab, newline).
  • ^Start of the string, or of a line with the m flag.
  • $End of the string, or of a line with the m flag.
  • *Zero or more of the preceding token.
  • +One or more of the preceding token.
  • ?Zero or one of the preceding token.
  • []A character class — any one listed character or range.
  • ()A capture group; also groups tokens together.
  • {}A repetition count, such as \d{4}.

Privacy

Matching and replacement run locally in your browser. The patterns and test text you enter are not uploaded to TechFixGen servers and are not included in analytics events. No account or signup is required. Need to escape a value before building a pattern or URL? Try the URL Encoder & Decoder.

Frequently asked questions

What regex engine does this tester use?

It uses the JavaScript RegExp engine built into your browser. That is exactly what runs in JavaScript code, but it is not PCRE, Python, .NET, Java, or RE2 — so patterns that rely on another engine's extensions may not behave the same way.

What does the g flag do?

The g (global) flag finds every match instead of only the first. Without it, the tester reports a single match and the replacement preview replaces just that first occurrence.

How do capture groups work?

Parentheses capture part of a match and are numbered from 1 in the order their opening parenthesis appears. Each match lists its numbered groups, their values, and their offsets. A group that did not participate is labelled accordingly.

Can I test multiline regex?

Yes. Paste multi-line text and enable the m flag to make ^ and $ match at each line break, or the s flag to let . match newline characters.

Does this support lookahead and lookbehind?

Lookahead is supported by all modern browsers. Lookbehind depends on the browser's JavaScript engine version, so support varies. This tester does not alter or emulate those features.

Is my test text uploaded?

No. Patterns, flags, test text, and replacements are evaluated entirely in your browser. They are not uploaded to TechFixGen servers and are not included in analytics events.