Regex Tester

Test regular expressions with live match highlighting, groups, flags, and replace—runs locally, no upload.

Loading tool…

By Muhammad Abdullah Rauf · Founder, EverydayTools.proUpdated 2026-05-20· Reviewed by EverydayTools Editorial Team

What is a regex tester?

A regex tester runs a JavaScript regular expression against sample text and shows matches, capture groups, flags, and replace output—entirely in your browser with no upload.

A regular expression (regex) is a pattern language for searching, validating, and transforming text. Developers use regex in logs, APIs, form validation, and editors—but small syntax errors cause silent failures. A regex tester lets you paste a pattern and test string, toggle flags (global, multiline, case-insensitive), and see highlighted matches with group details before shipping code.

This tool uses the same JavaScript RegExp engine as Node.js and browsers, so results match runtime behavior for most web apps. It is not PCRE/Python syntax—possessive quantifiers and some escape rules differ. Patterns and sample text stay on your device; nothing is sent to EverydayTools servers.

Pair with JSON Validator when extracting fields from payloads, or Text Diff when comparing pattern output across versions.

Quick answers

Concise answers for common searches — definitions, steps, and comparisons.

How do I match a literal dot in regex?

Escape it: \. matches a literal period. Inside [...] many specials are literal: [.*+] matches dot, star, or plus.

Greedy vs lazy quantifiers?

Greedy * + ? {n,m} take as much as possible. Lazy *? +? ?? {n,m}? take as little—useful between delimiters like <tag>...</tag>.

Is the regex tester private?

Yes. All matching runs in your browser; patterns and test text are not uploaded to servers.

How browser regex testing works

Patterns compile with new RegExp(pattern, flags) in an isolated Web Worker. Matches are collected with exec() in a loop when /g is set, with caps on match count and execution time to reduce ReDoS risk.

Formula

Match: RegExp.exec(testString) in loop
Replace: testString.replace(regex, replacement)

Limitations

  • JavaScript RegExp only—not PCRE, Python re, or Go syntax
  • Very large test strings may disable highlighting for performance
  • Not a security scanner—do not rely on regex alone for XSS or injection prevention

How to use Regex Tester

  1. Enter pattern and test string

    Paste your RegExp pattern and sample text—or load Email, URL, or other presets from the library.

  2. Set flags

    Enable global (g) for all matches, multiline (m) for line anchors, dotAll (s) so . matches newlines, and unicode (u) when needed.

  3. Review matches and groups

    Highlighted text shows each match; open match details for indices, numbered groups, and named groups.

  4. Test replace and share

    Optional replacement string previews substituted output. Copy a share link with pattern and flags encoded in the URL.

Regex Tester examples

Find all digits in a line

Input

Pattern \d+ on text "Order 42 costs $19.99"

Output

Matches 42 and 19, 99

With /g the engine finds every digit sequence; without /g only 42 matches.

Email preset smoke test

Input

Common email pattern vs alice+tag@sub.example.co.uk

Output

Match or no match with highlighted span

Validates practical format checks—not RFC-complete deliverability testing.

Who uses Regex Tester?

Common real-world scenarios where this tool saves time.

Validate email and URL patterns

Load common patterns, then test edge cases (subdomains, plus addressing, ports) before form validation code.

Parse logs and API responses

Extract timestamps, IDs, or log levels from sample lines—locally, without uploading production logs.

Debug replace and back-references

Preview replace output with $1/$2 or named $<group> before running sed or editor batch replace.

Learn pattern syntax

Use the pattern explainer to see what each token means while building complex lookaheads and character classes.

Workflow guides

Step-by-step chains that connect related tools for common tasks.

Email validation pattern

Test a practical email regex against a list of valid and invalid addresses.

  1. Enter pattern: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
  2. Set flags: none (single-line test per address).
  3. Paste test cases: alice@example.com, invalid@, missing-domain.com, user+tag@sub.domain.co — see which pass.
  4. For each failing case, adjust the pattern to handle the edge case or accept it as invalid.

URL matching workflow

Extract all URLs from a block of text using a regex.

  1. Enter pattern: /https?:\/\/[^\s"'<>]*/g
  2. Paste your text (HTML, markdown, log file, etc.) into the test field.
  3. Enable /g flag for all matches and review the matches panel.
  4. Refine the pattern to handle edge cases like trailing punctuation: /https?:\/\/[^\s"'<>,.;!?)]+/

From API sample to validated pattern

  1. Paste a sample response line into the test string field.
  2. Validate JSON structure first in JSON Validator if the payload is JSON.
  3. Build and test your regex with /g and the groups panel.
  4. Compare old vs new pattern output in Text Diff when refactoring extractors.

Phone number matching and normalization

Build a regex that matches common US and international phone number formats.

  1. Start with pattern: /^\+?1?[\s.-]?\(?([0-9]{3})\)?[\s.-]?([0-9]{3})[\s.-]?([0-9]{4})$/
  2. Test against formats: (555) 123-4567, 555.123.4567, +1-555-123-4567.
  3. Use capture groups (group 1 = area code, 2 = exchange, 3 = subscriber) for normalization in replace: '($1) $2-$3'.
  4. Add /m flag if testing one number per line in a multi-line input block.

Reference tables

Regex tester vs JSON tools

When to use each developer tool on EverydayTools.

ToolBest for
Regex TesterPattern match, groups, replace preview on arbitrary text
JSON ValidatorSyntax-valid JSON before parsing or formatting
JSON FormatterBeautify and minify JSON payloads
Text DiffCompare two text or code versions line by line

When to use Regex Tester vs related tools

Related toolUse this tool whenUse related tool when
JSON ValidatorYou need to match, extract, or replace patterns in arbitrary text — log lines, CSV, HTML, or any string content.You specifically need to validate whether a string is syntactically valid JSON before parsing it in your application.
Text DiffYou want to test a regex pattern against sample text and see which parts match.You have two versions of a text and need to see exactly which lines changed — without needing a regex pattern.

Common mistakes to avoid

Forgetting to escape . * + ?

Use \. for a literal dot. Outside a character class these operators are metacharacters.

Expecting PCRE-only features in JavaScript

No possessive ++ or atomic groups; use JavaScript-compatible patterns or test in the target language.

Advertisement

Frequently Asked Questions

Does this use JavaScript regex or PCRE?

JavaScript RegExp (ECMAScript) in your browser—the same engine as Node.js and front-end apps. PCRE/Python differ on possessive quantifiers, (?P<name>), and some escapes—re-test in your target runtime for production patterns.

What does the global flag (g) do?

With /g the engine finds every match and advances through the string. Without /g only the first match is returned—replace also affects only the first occurrence unless /g is set.

What are regex flags and what does each one do?

g = all matches; i = case-insensitive; m = ^ and $ per line; s = dot matches newlines; u = Unicode; d = match indices; v = unicode sets; y = sticky. Combine flags: /pattern/gim.

How do I test regex online?

Enter pattern and test text—matches highlight as you type. Turn on /g for all occurrences. Add a replacement to preview substituted text. Syntax errors show immediately with a clear message.

What is catastrophic backtracking (ReDoS)?

Nested quantifiers like (a+)+ can make the engine try exponentially many paths on non-matching input, freezing the tab. Avoid nested quantifiers on the same class; test long non-matching strings; this tool times out long runs in a worker.

What is the difference between .+ and .*?

.+ matches one or more of any character (except newline by default). .* matches zero or more — it can match an empty string. Both are greedy by default. Use .+ when at least one character is required. Add ? to make them lazy: .+? and .*? match as few characters as possible. The s flag makes . match newlines too.

How do I test a regex pattern for email validation?

A practical JavaScript email regex: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/. Enter it as the pattern and test against valid/invalid addresses. Note: no regex fully validates email per RFC 5322 — use it for basic format checks only. For authoritative validation, send a confirmation email.

What is a capture group in regex?

A capture group is a parenthesized subpattern that saves the matched text for later use. In /([0-9]+)-([a-z]+)/, group 1 captures the digits and group 2 captures the letters. You can reference captured groups in replacement strings ($1, $2 in JavaScript) or read them from the exec() result array. Named capture groups use (?<name>pattern) syntax: /(?<year>[0-9]{4})-(?<month>[0-9]{2})/.

What is a non-greedy match in regex?

Adding ? after a quantifier makes it non-greedy (lazy): it matches as few characters as possible. Example: /<.+?>/ on '<b>bold</b>' matches '<b>' and '</b>' separately. Without the ?, /<.+>/ would greedily match the entire '<b>bold</b>' string as a single match. Use lazy quantifiers when matching between delimiters.

What is a lookahead and lookbehind in regex?

Lookahead (?=pattern) asserts that what follows the current position matches pattern without consuming characters. Example: /\d+(?= dollars)/ matches digits followed by ' dollars' but doesn't include ' dollars' in the match. Negative lookahead: (?!pattern). Lookbehind (?<=pattern) asserts what precedes. Example: /(?<=\$)\d+/ matches digits after a dollar sign. JavaScript supports lookbehind since ES2018.

Can I use regex in JavaScript's replace() method?

Yes. 'hello world'.replace(/o/g, '0') → 'hell0 w0rld'. Without /g only the first match is replaced. In replacements, $& is the full match, $1 $2 are capture groups, $` is the text before the match, $' is the text after. You can also use a function as the replacement argument for dynamic substitutions: str.replace(/\d+/, n => n * 2).

What is the difference between \w and [a-zA-Z0-9_]?

\w is the word character shorthand and is equivalent to [a-zA-Z0-9_] in ASCII mode. With the u flag (Unicode mode) in JavaScript, \w still matches only ASCII word characters — not Unicode letters. To match Unicode letters, use \p{Letter} or \p{L} with the u or v flag: /\p{L}+/u. [a-zA-Z0-9_] is explicitly ASCII only regardless of flags.

How do I match multiline text in regex?

Use the m flag to make ^ match the start of each line and $ match the end. Without /m, ^ and $ anchor to the start/end of the entire string. The s (dotAll) flag makes . match newlines, enabling patterns like /<div>[\s\S]*?<\/div>/s or /<div>.*?<\/div>/s to span lines.

What do ^ and $ mean in regex?

^ asserts the start of the string (or start of line with /m flag). $ asserts the end of the string (or end of line with /m). Pattern /^hello/ only matches strings that begin with 'hello'. /world$/ matches strings ending with 'world'. /^hello world$/ matches the exact string 'hello world'. Without anchors, a pattern matches anywhere in the string.

How do I match a phone number with regex?

A practical US phone regex: /^\+?1?[\s.-]?\(?([0-9]{3})\)?[\s.-]?([0-9]{3})[\s.-]?([0-9]{4})$/. Test variants like (555) 123-4567, 555-123-4567, and +1 555 123 4567. For international numbers, use libphonenumber (Google's library) rather than regex — international formats vary too widely for a single pattern.

Privacy, accuracy, and trust

Privacy

Patterns and test strings are evaluated in a browser Web Worker. Nothing is uploaded to EverydayTools—safe for logs containing tokens or personal data.

Accuracy

Uses the native JavaScript RegExp engine—the same semantics as Node.js and modern browsers for the flags you select.

For debugging and learning patterns—not a substitute for security review or production ReDoS audits on user-supplied regex.

Part of Developer Tools

More free tools for the same workflow.

Advertisement

Reviewed by EverydayTools Editorial Team on 2026-05-20.