Text Tools

Regex Tester

See matches and line-by-line results before using a pattern in an application.

Matches

  • softkey-tools
  • release_2026

Line checks

  • Match: softkey-tools
  • Match: release_2026
  • No match: invalid value

Understand the format

How Regex Tester works

A pattern is only as good as the examples it has been tried against, including the ones that must fail. This tester shows both the matches found and a pass or fail verdict for each line.

Two views of the same pattern

The Matches list runs the expression globally across the whole sample and shows every substring it found, which is the right view when you are extracting data from logs or free text. The Line checks list runs the pattern once per line and reports whether that line matched, which is the right view when the pattern is a field validator.

The distinction matters because an unanchored pattern can produce a match on almost every line while still failing as a validator. Reading both views together is what exposes that: many matches but a line you expected to fail marked as matched means the pattern needs anchors.

Flags change the meaning, not just the speed

The g flag finds every match rather than stopping at the first. The i flag ignores case. The m flag makes ^ and $ match at each line boundary instead of only at the start and end of the whole input, which is exactly what you want when testing a multi-line sample. The s flag lets a dot match newlines, and u enables Unicode-aware matching including property escapes.

Because m changes what anchors mean, a pattern that appears to work on a multi-line sample can behave completely differently against a single value in production. Always test with the same flags the application will use.

Step by step

How to use Regex Tester

  1. Enter the pattern without surrounding slashes, then the flags you intend to use in your application.
  2. Paste sample text with one candidate value per line, including values that must be rejected.
  3. Read the Matches list to see what the pattern extracts, and the Line checks list for a per-line verdict.
  4. Add a new line to the sample every time production reveals a case you had not considered.

Patterns and sample text are evaluated by the browser regex engine in the page, so log excerpts used as samples never leave your machine.

Worked examples

Regex Tester examples explained

An anchored slug validator

Input

pattern ^[a-z0-9_-]+$ with flags gm against three lines

Result

softkey-tools  -> Match
release_2026   -> Match
invalid value  -> No match

The third line fails on the space, which is the intended behaviour. Without the anchors it would match the fragment "invalid" and pass.

Greedy versus lazy quantifiers

Input

pattern <.+> against <a><b>, then <.+?>

Result

<a><b>  vs  <a> and <b>

The greedy .+ consumes as much as possible and returns one long match. Adding ? makes it lazy, so each tag is matched separately.

Reference

Flags and what each one changes

Flags and what each one changes
FlagNameEffect
gGlobalReturns every match instead of only the first.
iIgnore caseLetter comparisons become case-insensitive.
mMultilineMakes ^ and $ match at each line break.
sDot allAllows the dot to match newline characters.
uUnicodeEnables code-point matching and \p{...} property escapes.
yStickyMatches only at the current index, used for tokenisers.

Practical Guide

How teams use Regex Tester

Common use cases

  • Verify capture behaviour for email, slug, token, and log-line patterns.
  • Check how a pattern behaves against multiline text copied from logs or traces.
  • Reproduce a bug report where a field passed or failed validation unexpectedly.

Checks before trusting the result

  • One passing example is not a test; include negative cases that must fail.
  • Watch for greedy matches and unintended partial matches inside long strings.
  • Keep flags and anchors identical to the runtime where the pattern will execute.

Troubleshooting

Common mistakes and how to fix them

A pattern behaves differently in application code than in a tester.
Check the flags and the escaping. A pattern written in a string literal needs its backslashes doubled, so \d becomes \\d.
Nested quantifiers such as (a+)+ against a long non-matching string.
This is catastrophic backtracking, the basis of regular-expression denial of service. Rewrite to avoid nesting, or apply a length limit before matching.
Reusing a global regex object and getting alternating results.
A regex with the g flag keeps a lastIndex between calls to test and exec. Create a fresh instance, or reset lastIndex to zero.

FAQ

Regex Tester questions, answered

Should I include the slashes around my pattern?

No. Enter the pattern body only and put the flags in the flags field, the same way most languages construct a regex from a string.

Why does a line match when I expected it to fail?

The pattern is probably unanchored, so it matched a fragment. Add ^ and $ to require the whole line to match.

What is catastrophic backtracking?

A pattern whose alternatives multiply on a non-matching input, so the engine explores an exponential number of paths. It can freeze a server thread on a single request, which is why untrusted input needs both a length limit and a reviewed pattern.

Does this run JavaScript regular expressions?

Yes, the browser engine. Basic syntax matches other ecosystems, but lookbehind, named groups, and Unicode handling vary, so confirm in your own runtime.

Can I test capture groups?

The Matches list shows full matches. To inspect individual groups, temporarily reduce the pattern to the group you care about, or test it in the runtime that will consume the captures.

Go deeper

Specifications and guides