Glyph WidgetsGlyph Widgets
AboutContactBlogPrivacyTermsSupport on Ko-fi

© 2026 Glyph Widgets. All rights reserved.

·

100% Client-Side Processing

Back to Blog

Regex Tester: Test Patterns with Matches

Regex tester: debug regular expressions with live match highlighting, capture group display, and all regex flag support. Free, no signup.

Glyph Widgets
February 27, 2026
11 min read
regex testerregex onlineregular expression testerregex debuggerregex validator

What Is the Regex Tester?

The Regex Tester is a free, browser-based tool for writing, testing, and debugging regular expressions with real-time feedback. It solves the core problem that regex development has always had: you cannot know whether a pattern is correct until you test it against real text, and the edit-run-check cycle in most environments is slow and fragmented.

Here, you type a pattern and it evaluates instantly. Matches are highlighted directly in your test string, capture groups are extracted and labeled, character positions are reported for every match, and a replace mode lets you preview substitutions before putting them into production code. All six JavaScript regex flags are supported. A library of 49 pre-built patterns organized by category is available for common validation needs. The tool works entirely in the browser — your patterns and test data are never sent anywhere.

Key Features

  • Live matching as you type — Matches are recalculated on every keystroke using JavaScript's native RegExp engine. The result panel updates without any button press.
  • All JavaScript regex flags (g, i, m, s, u, y) — Each flag is a labeled checkbox: global, case-insensitive, multiline, dotAll, unicode, and sticky. The active flags are shown in a code badge next to the pattern input, mirroring the /pattern/flags notation used in JavaScript source code.
  • Match highlighting in test string — The Matches Highlighted panel renders your test string with every match wrapped in a <mark> element styled with a primary-color background. Non-matching text appears unstyled. The panel shows a live match count.
  • Capture group extraction — The Match Details panel appears whenever there are matches. Each match entry shows the full match text, its start and end character positions, and a labeled list of capture groups ($1, $2, etc.). Groups with no content are labeled "empty".
  • Match count and positions — Every match entry in the details panel shows the exact index and index + match.length positions, which correspond directly to the index property on JavaScript RegExpExecArray.
  • Replace mode with substitution — A toggleable replace section takes a replacement string and shows the full substitution result. Supports back-references ($1, $2). The result can be copied to the clipboard.
  • Common regex patterns library — A searchable pattern library with 49 patterns across 8 categories: Validation, Dates & Times, Numbers, Web & Network, Files & Paths, Code, Text, and Identifiers. Clicking "Use Pattern" loads it into the pattern input.

How to Use the Regex Tester

Step 1: Enter Your Pattern

Type your regular expression into the pattern input field. The field is displayed with / delimiters on each side to visually indicate the regex format. You do not include the slashes in what you type — only the pattern body.

If your pattern has a syntax error (such as an unclosed group or an invalid escape sequence), an error message appears immediately in red below the pattern input, with the exact error text from JavaScript's RegExp constructor. You cannot run a broken pattern, but the error message identifies precisely what is wrong.

Step 2: Set Your Flags

Below the pattern input are six flag checkboxes. By default, the g (global) flag is enabled. Toggle flags by clicking their checkboxes:

  • g (global) — find all matches, not just the first
  • i (case-insensitive) — treat uppercase and lowercase as equivalent
  • m (multiline) — make ^ and $ match the start and end of each line, not just the whole string
  • s (dotAll) — make . match newline characters as well as all other characters
  • u (unicode) — enable full Unicode support; required for patterns that use \p{} Unicode property escapes
  • y (sticky) — match only at the current position in the string (lastIndex), without searching ahead

The active flags string is shown live next to the pattern field, so gi would appear if both global and case-insensitive are checked.

Step 3: Enter Your Test String

Paste or type the text you want to match against in the Test String panel. The character count for the test string is shown in the panel header. The textarea accepts multi-line input and resizes vertically.

Step 4: Read the Match Results

The Matches Highlighted panel on the right updates instantly. Every portion of the test string that matches your pattern is highlighted. The panel header shows the total match count.

Below the two main panels, a Match Details section appears listing each match individually:

  • Match number (1-indexed)
  • The matched text, displayed in a highlighted code block
  • Character positions: start index and end index
  • Capture groups, labeled $1, $2, etc.

Step 5: Use Replace Mode (Optional)

Click the "Show Replace" button to open the replace section. Enter a replacement string in the Replace With field. Back-references work: $1 inserts the content of the first capture group, $2 the second, and so on. The Result panel updates immediately showing the full substitution result. Click the copy icon to copy the result.

Step 6: Use the Pattern Library (Optional)

Click the "Pattern Library" button to open the searchable pattern panel. Type in the search box to filter by name, description, or category. Click "Use Pattern" next to any entry to load it directly into the pattern field. The library closes automatically after selection.

Practical Examples

Example 1: Validate Email Addresses

Pattern: ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$

Flags: g

Test string:

user@example.com
invalid-email
another@test.co.uk
@missing-local.com

Result: Two matches — user@example.com and another@test.co.uk are highlighted. The other two lines produce no matches.

Example 2: Extract Capture Groups from Log Lines

Pattern: (\d{4}-\d{2}-\d{2}) (\w+): (.+)

Flags: gm

Test string:

2026-02-28 ERROR: Connection timeout after 30s
2026-02-27 INFO: Server started on port 3000

Match Details for Match 1:

  • Full match: 2026-02-28 ERROR: Connection timeout after 30s
  • $1: 2026-02-28
  • $2: ERROR
  • $3: Connection timeout after 30s

Example 3: Replace With Capture Group Back-References

Pattern: (\w+)\s(\w+) Replace with: $2, $1 Test string: John Smith Result: Smith, John

This demonstrates the replace mode using $1 and $2 to swap the order of two captured word groups.

Tips and Best Practices

Enable global flag for comprehensive testing. With g off, matching stops after the first result. During development you typically want g enabled to see all potential matches across your test string and verify there are no unexpected extra matches.

Use the m (multiline) flag when your pattern uses ^ or $. Without m, ^ matches only the very start of the entire input string and $ matches only the very end. With m, they match at the start and end of each line, which is almost always what you want when processing multi-line input.

Zero-length match protection is built in. When the global flag is active, the matching loop checks for zero-length matches and increments lastIndex to prevent an infinite loop. This means patterns like a* or \b will not hang the browser.

Copy the pattern in /pattern/flags notation. The Copy Pattern button writes the full pattern to the clipboard in JavaScript notation, including the slashes and the active flags — for example /\d{4}-\d{2}-\d{2}/gm. You can paste this directly into JavaScript source code.

Save patterns to Snippets. The Save to Snippets button (visible next to Copy Pattern) stores your current pattern — in /pattern/flags format — to the Snippets library available through the Glyph Widgets supporter features. This is more durable than relying on session history alone.

Common Issues and Troubleshooting

Pattern shows a red error message. The error text comes directly from the JavaScript RegExp constructor and describes what went wrong. Common errors include Invalid regular expression: missing ) (unclosed capture group) and Invalid escape (a backslash followed by a character that is not a valid escape sequence without the u flag). Read the error message literally — it specifies the problem.

Expected matches are not highlighting. Check whether you need the i flag for case-insensitive matching, or the m flag if your pattern uses ^ or $ on multi-line input. Also verify that the pattern is not anchored too tightly — ^\d+$ only matches a line containing only digits, not digits embedded in other text.

Capture groups show "empty". A capture group is "empty" when the group participates in the match but the sub-pattern matched zero characters, or when an optional group ((...)?) did not participate. This is distinct from a group that was not in the pattern at all.

Replace result does not use back-references. Back-references in the replacement string use the $1, $2, $n syntax. Using \1 or %1 will not work — those are not valid in JavaScript's String.prototype.replace. Named groups use $<name> syntax.

Pattern loads from the library but does not match. Some library patterns include anchors (^ and $) and are designed for whole-string validation, not substring matching within a larger test string. If you are searching for the pattern inside a paragraph, remove the anchors or add g without m to see if the core pattern matches.

Privacy and Security

All regular expression evaluation in the Regex Tester runs in your browser using JavaScript's native RegExp engine. No patterns, no test strings, and no match results are transmitted to any server. The shareable URL feature encodes your pattern and test string into the URL itself (client-side only), so sharing a link does not involve a server round-trip. The tool works offline after the initial page load.

Frequently Asked Questions

Is the Regex Tester free? Yes, completely free with no account, no signup, and no usage limits.

Is my data safe? Your patterns and test strings never leave your browser. All matching runs locally using JavaScript's built-in RegExp. The tool has no server-side component involved in the matching process.

Can I use it offline? Yes. Once the page is loaded, the entire tool works without an internet connection. The pattern library, matching engine, and replace mode all run locally.

What regex flavor does this use? The tool uses JavaScript's native RegExp engine, which implements the ECMAScript regular expression specification. This supports most common regex syntax including lookaheads, lookbehinds (in modern JS), capture groups, non-capturing groups, backreferences, and Unicode property escapes (with the u flag).

Does it support lookaheads and lookbehinds? Yes. Positive lookaheads (?=...), negative lookaheads (?!...), positive lookbehinds (?<=...), and negative lookbehinds (?<!...) are all supported by the JavaScript engine used here, as they are part of the ECMAScript 2018 specification and supported by all modern browsers.

Can I share my pattern with someone else? Yes. The tool uses shareable state that encodes your pattern, test string, and flags into the URL. Copy the URL from your browser's address bar and share it. When the recipient opens the link, a toast notification informs them the state was loaded from a shared URL.

How many patterns are in the pattern library? The library contains 49 patterns organized into 8 categories: Validation (10 patterns including email, URL, phone, UUID, password), Dates & Times (5 patterns), Numbers (5 patterns), Web & Network (6 patterns), Files & Paths (5 patterns), Code (6 patterns), Text (7 patterns), and Identifiers (5 patterns including credit card, SSN, IBAN, ISBN-13, and IMEI).

What is the difference between the s (dotAll) and m (multiline) flags? They affect different things. The s flag makes . match newlines in addition to all other characters. Without it, . skips newline characters. The m flag makes ^ and $ match at the start and end of each line rather than the whole string. They are independent — you can enable either, both, or neither.

Can I use Unicode property escapes like \p{Letter}? Yes, but the u flag must be enabled. With u active, patterns like \p{Lu} (uppercase letter) and \p{Script=Latin} are supported by modern browsers. Without u, the \p sequence is treated as a literal p.

How do I match across multiple lines? Enable the s (dotAll) flag so . matches newlines, then use [\s\S]*? or simply .+ with s active. Also enable m if you need ^ and $ to anchor to line starts and ends.

Related Tools

  • JSON Formatter — Format JSON for use as regex test strings
  • Base64 Encoder/Decoder — Encode/decode text you need to regex against
  • Diff Checker — Compare original and replaced text side by side

Try Regex Tester now: Regex Tester

Last updated: February 27, 2026

Keep Reading

More ArticlesTry Regex Tester