Skip to content

Development

Regex Tester

Test regular expressions against sample text.

Loading tool…

Find this tool in

About this tool

What is Regex Tester?

Try a JavaScript regular expression against a small text sample before using it in code or a search workflow. Choose flags explicitly and inspect the actual matches rather than relying on a pattern's appearance. The isolated worker bounds execution time, but a successful small example does not establish performance on every possible large input.

A worked example

Match a whole word rather than part of a longer word

Example input

\bcat\b
flag: g
text: cat scatter cat

Expected result

0: cat
12: cat

Put the pattern and sample text in their separate fields and enable the global flag. The two standalone instances match; the letters inside scatter do not. The indexes describe JavaScript string positions. Use a separate example containing punctuation and non-ASCII writing when those cases are part of the real input you intend to search.

Common mistakes and limits

  • Regular-expression syntax and word-boundary behavior differ across engines and flags. A JavaScript result does not establish compatibility with another language's engine.
  • If a pattern times out, simplify it and test adversarial input. Do not assume increasing an execution limit is a safe fix for excessive backtracking.

Features

What you can do

  • Test JavaScript-compatible regular expressions.
  • Enable global, case-insensitive and multiline flags.
  • Inspect match positions and captured groups.
  • Display named capture groups separately.
  • Detect invalid regular expression syntax.
  • Evaluate all patterns locally in the browser.

Frequently asked questions

Questions about Regex Tester

Which regular expression syntax does this tool use?

The tester uses the JavaScript RegExp implementation provided by your browser. Some syntax available in other engines, such as PCRE-specific features, may not be supported.

What does the global flag do?

The g flag finds every non-overlapping match. Without it, JavaScript normally returns only the first match.

What is a capture group?

A capture group is a parenthesized part of a regular expression whose matched value is returned separately from the complete match.

Can a regular expression freeze the browser?

Poorly designed expressions can cause excessive backtracking and become slow on certain inputs. Avoid testing untrusted or extremely complex patterns against very large text.

Related tools