Regex Tester

Test JavaScript regular expressions with live match highlighting, replace and split previews, capture groups, CSV export, presets, and saved snippets. Everything runs locally in your browser.

/g

Test String & Result

This is a sample test string with several five-letter words. Email me: hello@example.com or visit https://onlinetextlab.com.

Regex Cheat Sheet

Character Classes
.Any character except newline
\dDigit (0-9)
\DNot a digit
\wWord character
\WNot a word character
\sWhitespace
\SNot whitespace
Anchors
^Start of string
$End of string
\bWord boundary
\BNot a word boundary
Groups and Lookarounds
(abc)Capture group
(?:abc)Non-capturing group
(?=abc)Positive lookahead
(?!abc)Negative lookahead
Quantifiers
a*0 or more
a+1 or more
a?0 or 1
a{3}Exactly 3
a{2,}2 or more
a{1,4}1 to 4
Flags (Modifiers)
gGlobal
iCase-insensitive
mMulti-line (^ and $ match line boundaries)
sDotAll (dot matches newline)
uUnicode
ySticky

Matches (5)

MatchStartEndGroups
words5459
Email6166
hello7176
visit9297
https98103

Regex Explanation

\bWord boundary
\wWord character (a-z, A-Z, 0-9, _)
{5}Exactly 5 times
\bWord boundary

Snippets

No saved snippets yet.

TL;DR — write a regex, paste text, see matches live

Type a pattern, toggle flags, and preview Match, Replace, or Split in real time. See start/end indexes and capture groups, export CSV, and save snippets. Runs 100% in your browser.

Regex Tester – Test and Debug Regular Expressions Online Free (JavaScript)

Test JavaScript regular expressions online with live match highlighting. Supports all flags (g, i, m, s, u), capture groups, named groups, replace and split modes, CSV export, and saved snippets. Type a pattern, toggle flags, and watch matches highlight instantly. Switch tabs to preview Match, Replace, or Split. The matches panel lists each hit with start/end indexes and capture groups, so you can debug quickly without leaving the browser.

Prefer a regex creator feel? Use presets (email, URL, dates, phone, IPv4), read the token‑by‑token explanation, and skim the built‑in cheat sheet. Save your own snippets for reuse or export results to CSV. Everything runs locally with the JavaScript RegExp engine, making this a practical regex checker, editor, and quick builder in one.

Applying patterns to full documents? Try Find & Replace. Extracting web addresses? Use the URL Extractor. Cleaning inputs first? Text Cleaner helps a ton.

Common regex use cases

Regular expressions are useful across many everyday tasks: email validation to check address format, phone number matching across various formats, URL extraction from documents or logs, log parsing to pull timestamps and error codes, find-and-replace patterns for bulk text transformations, and input sanitization to strip or reject unwanted characters before processing.

Quick start

  1. Enter a pattern (e.g. /\\w+/g or just \\w+) and toggle flags (g, i, m, s, u, y). Or pick a preset to begin faster.
  2. Paste a test string. Use Match to highlight hits, Replace to preview substitutions (with $1, $2 …), or Split to segment text.
  3. Inspect the Matches table for indexes and groups, export CSV, copy your pattern, or save a named snippet for later.

Key features

  • Live Match / Replace / Split previews
  • Start & end indexes plus capture groups for each hit
  • Token‑by‑token explanation of your pattern
  • Presets: email, URL, date, phone, IPv4
  • Cheat sheet and user‑saved snippets
  • CSV export of matches; one‑click copy of regex and results
  • Undo/redo for pattern edits; flag toggles (g/i/m/s/u/y)
  • 100% client‑side — fast, private, and offline‑friendly

Tips

  • Start simple; add anchors (^, $) and quantifiers gradually.
  • Use non‑capturing groups (?: … ) when you don’t need backreferences.
  • Prefer explicit character classes over dots when possible.
  • Test edge cases: empty lines, Unicode, and newlines (try the s and m flags).
  • Beware zero‑length matches; ensure your pattern advances through the string.

Frequently asked questions

Which regex flavor does this use?
The tool uses the JavaScript RegExp engine in your browser. Many patterns are portable, but flavors differ—confirm in your target runtime.
Can I use it as an online regex builder?
Yes—the presets, explanation panel, and cheat sheet make it a lightweight regular expression builder. Tweak and see results instantly.
Why don’t my results match another tester?
Engines and defaults vary (e.g., dotAll, multiline, Unicode). Double‑check flags and flavor specifics when comparing.
Is my data private?
Yes—everything runs locally; nothing is uploaded.
How do I test a regular expression online for free?
Paste your regex pattern in the pattern field and your test string below it. Matches are highlighted in real time as you type. No account needed — the JavaScript RegExp engine runs entirely in your browser.
How do I match an email address with regex?
Use the built-in Email preset or write a pattern like [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. Test it against sample addresses to verify edge cases like subdomains and plus-addressing.
What does the g (global) flag do in JavaScript regex?
The g flag finds all matches in a string, not just the first one. Without g, the regex stops after the first match. Toggle the flag in the flags bar to see the difference instantly.
Can I extract capture groups with this regex tester?
Yes. The capture groups table shows all named and numbered groups for each match. Switch to Replace mode and use $1, $2, or named references in the replacement string.

You might also like