Regex Tester

Test regular expressions against sample text.

What Regex Tester helps you do

Test a JavaScript regular expression against sample text and list every full match. It uses the built-in RegExp engine and matchAll, so it reflects how JavaScript itself would behave. Patterns, flags and test string all update the result as you type.

Testing runs in your browser using the built-in regex engine. Your text is not uploaded.

How it works

These tools transform text locally: they parse, format, encode or render a string in your browser. Nothing you paste is uploaded to Haivix, but some tools load a library from a public CDN, so the page needs a network connection and your browser makes that request. The transformations operate on syntax, not meaning: a formatter can make invalid code look tidy, an encoder can hide a value without protecting it, and a preview can render markup that was never meant to execute. Outputs are exact strings, which means line endings, byte order marks and character encoding all matter when you paste the result somewhere else.

How to use Regex Tester

  1. Enter the pattern without slashes.
  2. Set the flags, keeping g for multiple matches.
  3. Paste the test string and read the match list.
  4. Refine the pattern and copy the working version.

When to use it

  • Debug a pattern that is not matching what you expect.
  • Check how many matches a global pattern finds.
  • Build a validation pattern against representative samples.
  • Test a flag combination before using it in code.
  • Check the exact text a pattern captures.
  • Compare the JavaScript result with another engine.

When not to use it

  • Do not expect capture groups to be displayed separately; only full matches are listed.
  • Do not use it for PCRE, Python or .NET-only constructs.
  • Do not test a catastrophic-backtracking pattern on a large input.

Example

The pattern for a date highlights each date-shaped substring and lists the matched text. With the g flag it finds every occurrence; without g, matchAll throws and the page shows an error. Capture groups are part of the match but are not broken out into separate columns.

What you can do with Regex Tester

  • Run a JavaScript regular expression against sample text.
  • Accept custom flags such as g, i and m.
  • List every full match.
  • Report the match count.
  • Show syntax errors without breaking the page.
  • Run the test locally in the browser.

Example: test with a real sample before trusting the output

Keep the original text. These tools produce a new value rather than editing in place, so a bad transform is reversible only if you still have the source.

Test with a representative sample, including the awkward case: a quote inside a string, a tag inside an attribute, a newline in the middle of a value.

Check line endings and encoding when moving between Windows, Unix and a browser form. A trailing carriage return can break a signature or a hash.

Treat pasted HTML and Markdown as untrusted. A preview that renders raw markup can execute event handlers even when it looks harmless.

Verify the result with the real parser, compiler or linter before shipping. A browser-side formatter is a convenience, not a substitute for the toolchain.

Prefer exact values over screenshots or copied rendered text. Rendering can normalize quotes, dashes and spaces in ways that break the next tool in the chain.

What to know before you start

  • It uses JavaScript regular expression syntax, which differs from PCRE or Python in some constructs.
  • Catastrophic backtracking can make some patterns slow; keep samples small when testing risky expressions.
  • Only full matches are listed; capture groups are not shown separately.
  • No highlighting is drawn on the source text; matches appear only in the list.
  • There is no replace, split or export mode.

Common mistakes

  • Forgetting the g flag and getting an error.
  • Including the surrounding slashes in the pattern field.
  • Expecting lookbehind or named groups to work in every browser.
  • Testing a risky pattern on a huge string and freezing the tab.

Troubleshooting

If an error mentions a non-global regex, add g to the flags.

If a pattern is invalid, check escaping and bracket balance.

If the match count is zero, confirm the flags and the sample text.

If the page hangs, the pattern may be catastrophically backtracking; reload and simplify it.

If an error mentions an invalid flag, check the flags field for stray characters.

Related standards and documentation

  • ECMA-404 defines JSON, and RFC 8259 defines its media type.
  • XML 1.0 is a W3C Recommendation; schemas are defined separately by XSD.
  • ECMA-262 defines JavaScript, including its regular expression syntax.
  • RFC 3986 defines URI syntax and percent-encoding.
  • CommonMark specifies Markdown, though many renderers extend it.
  • The HTML Living Standard defines character references and parsing rules.
  • Unicode defines the character encodings behind text and entity handling.
Syntax, not semantics
  • Keep the source.
  • Test the awkward case.
  • Check encoding and newlines.
  • Verify with the real tool.