Regex Tester

Developer tool for building and validating regex patterns with comprehensive analysis.

Regular Expression

Flags

g

Length

0

Named groups

None

Flags & Options

Samples

History

No entries yet

Test String

Replacement Preview

Provide a replacement string to preview transformed output.

Highlighted Matches

Provide a test string to view highlighted matches.

Match Details

Run the regex to see per-match breakdowns here.

Match Summary

Live metrics update with each edit.

Matches

0

Groups

0

Execution

0 ms

Input size

0 chars

Words

0

Lines

0

Named groups

None

About Regex Tester Tool

Experiment with JavaScript regular expressions using real-time feedback, syntax highlighting, match statistics, and replacement previews. Everything runs locally in your browser for speed and privacy.

Key Capabilities

  • Instant validation: See whether your pattern parses and how long execution takes.
  • Live highlighting: Visualize matches directly inside the test text.
  • Advanced flags: Toggle g, i, m, u, s, and y options.
  • Replacement preview: Enter replacement strings (including captured groups) to view transformed output.
  • Detailed analysis: Inspect indices, context, capture groups, and named groups for every match.
  • History & samples: Quickly load curated examples or revisit saved patterns.

Usage Workflow

  1. Enter a regular expression and optional replacement string.
  2. Add or paste test data into the Test String panel (uploading a file works too).
  3. Modify flags to control case sensitivity, multiline anchors, Unicode handling, DotAll behaviour, or sticky matching.
  4. Click Run Regex (or simply type—evaluation happens automatically).
  5. Review highlighted matches, summary statistics, and per-match details.
  6. Export the results as JSON or copy outputs to the clipboard.

Interactive Examples

Open the Samples dropdown to preload curated scenarios. Each one highlights a different regex concept—run them as provided, tweak the pattern, then re-run to see how the outputs change.

  • Email Addresses: ([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+.[A-Za-z]{2,}): Captures user and domain parts. Try toggling i for strict case checks or add + to require a top-level domain.
  • ISO Dates: (?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01]): Demonstrates named groups and numeric ranges. Experiment with invalid months to observe failed matches.
  • URLs: (https?):\/\/([\w.-]+)(\/[\w./?%&=-]*)?: Breaks out protocol, host, and optional path. Toggle g to find every link and i to allow mixed-case schemes.
  • Hex Colors: #(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b: Matches shorthand and long-form CSS colors. Use replacements like color:$&; to see the live substitution preview.
  • Markdown Links: [(?<label>[^\]]+)]((?<url>[^\s)]+)(?:\s"(?<title>[^"]+)")?): Extracts label, URL, and optional title. Inspect the match details pane to see named captures in action.

Build on the samples

  • Duplicate a sample into history, then iterate on stricter or more permissive variants.
  • Combine snippets—for instance, nest the date pattern inside the URL sample to catch timestamped resources.
  • Switch to your own data by uploading logs, configuration files, or markdown content for real-world practice.

Flag Reference

  • g (global) – continue searching after the first match.
  • i (ignore case) – case-insensitive comparisons.
  • m (multiline) – treat ^ and $ as line anchors.
  • u (unicode) – enable Unicode mode and property escapes like \p{Letter}.
  • s (dotAll) – allow . to match newline characters.
  • y (sticky) – match from the current index without skipping ahead.

Replacement Tips

  • Use $1, $2, … for numbered capture groups.
  • Use $& for the entire match, $` for the prefix, and $' for the suffix.
  • Named groups can be referenced as $<groupName> when the Unicode flag is enabled.

Best Practices

  • Start with provided samples to verify behaviour before adapting to your data.
  • Keep auto-save enabled to preserve your work between sessions.
  • Watch the execution time metric when crafting complex expressions.
  • Use the history panel to compare different pattern strategies.

All processing occurs client-side; no data ever leaves your browser.