Skip to content
DevelopmentAvailableFreeRuns locally

Regex Tester

Test JavaScript regular expressions, inspect matches, and review capture groups directly in your browser.

Test a JavaScript regular expression

Enter a pattern, choose JavaScript flags, and test it against text locally.

Enter the pattern only, without surrounding slash characters. Maximum 5,000 characters.

Flags

Multiline text and Unicode are supported. Maximum 200,000 characters.

Your regular expression and test text are processed locally in your browser and are not sent to a server.

Regular expression performance
Complex or malicious regular expressions can require substantial computation and may temporarily make the browser unresponsive. This tool does not provide regex timeout protection.

Overview

What is a regular expression?

A regular expression, often called a regex, is a pattern for searching, matching, validating, and processing text. Developers use regex for tasks such as locating values, checking input formats, and extracting structured parts from strings.

This tester uses JavaScript regular expression syntax. Results can differ from regex engines used by other programming languages and platforms.

Steps

How to test a regex

  1. Enter a pattern without surrounding slash characters.
  2. Select the JavaScript flags required by the pattern.
  3. Paste or type a test string.
  4. Select Test Regex.
  5. Review the match summary, highlighted text, indexes, and capture groups.

Reference

JavaScript regex flags

  • g finds successive matches globally.
  • i enables case-insensitive matching.
  • m changes line anchors so ^ and $ work across lines.
  • s enables DotAll behavior so a dot can match line terminators.
  • u enables Unicode-aware pattern processing.
  • y enables sticky matching at the current lastIndex.

Example

Regex example

An email-like pattern can locate addresses in ordinary text:

Pattern: \b[\w.%+-]+@[\w.-]+\.[A-Za-z]{2,}\b
Test: alice@sample.test
Match: alice@sample.test

This example demonstrates matching only. Production email validation usually requires application-specific rules beyond a single regular expression.

Extraction

Regex capture groups

Parentheses such as (...) create numbered capture groups. A pattern like(\w+)@(\w+\.\w+) can preserve the username as Group 1 and the domain as Group 2.

JavaScript named groups use syntax such as (?<user>...). When the browser provides named group results, this tester lists each name and value separately.

Behavior

Greedy vs lazy matching

A greedy quantifier such as .* consumes as much text as possible while still allowing the pattern to match. A lazy quantifier such as .*? consumes as little as possible. Choose the form that matches the boundaries your data requires.

Troubleshooting

Common regex mistakes

  • Forgetting to escape a character that has special regex meaning.
  • Leaving a group or character class unclosed.
  • Selecting the wrong flags or forgetting a required flag.
  • Using anchors that do not match the intended line behavior.
  • Using an overly broad expression such as .*.

Structured formats should use their own parser where possible. For JSON grammar and parsing errors, use the JSON Validatorinstead of approximating complete JSON syntax with a regular expression.

Compatibility

JavaScript regex vs other regex engines

JavaScript RegExp, PCRE, Python, Java, .NET, and RE2 share many concepts, but their syntax, feature support, flags, and edge cases are not identical. A successful result in this JavaScript regex tester is not a guarantee that the same pattern works unchanged elsewhere.

Performance

Regex performance

Some patterns can trigger catastrophic backtracking when applied to particular input. JavaScript RegExp has no simple built-in timeout, so complex or untrusted patterns can temporarily block the browser thread. Keep patterns specific and test them with realistic, bounded input before production use.

Workflows

Common regex testing use cases

  • Check a JavaScript pattern against representative input before adding it to code.
  • Compare global, case-insensitive, multiline, Unicode, and other flag behavior.
  • Inspect capture groups and match indexes while debugging extraction logic.
  • Identify greedy matching, escaping mistakes, or patterns that may backtrack heavily.

FAQ

Frequently asked questions

What is a regex tester?

A regex tester runs a regular expression against sample text so you can inspect matches, indexes, capture groups, and pattern behavior before using it in code.

Which regex engine does this tool use?

This tester uses the JavaScript RegExp engine provided by your browser. JavaScript syntax and behavior can differ from PCRE, Python, Java, .NET, RE2, and other engines.

What does the g flag do?

The g flag enables global matching, which finds successive non-overlapping matches. Without g, JavaScript RegExp returns only the first match.

What are capture groups?

Parentheses create capture groups that preserve matched subexpressions. JavaScript also supports named groups with syntax such as (?<name>...).

Why is my regular expression invalid?

Common causes include an unclosed group, an incomplete character class, invalid escaping, or syntax that the browser JavaScript RegExp engine does not support.

Does this tool upload my text?

No. Your pattern and test text are processed locally by JavaScript in your browser and are not sent to a server.

Can regular expressions be slow?

Yes. Some patterns can cause extensive backtracking and temporarily block the browser thread. This tool does not claim to provide regex timeout or ReDoS protection.

What is the difference between JavaScript regex and PCRE?

They are different regex engines with overlapping but non-identical syntax, flags, and features. A pattern tested here should be checked again in the engine used by its target application.