ToolMight LogoToolMight

RegEx Tester

Test and debug regular expressions instantly with live match highlighting and capture group inspection.

Loading Tool...
Sponsored

Test, validate, and debug JavaScript regular expressions in real time. Highlight match occurrences, inspect capture groups, and experiment with flags instantly using this browser-native regex debugger and tester.

Learn About This Tool

Understanding javascript regular expressions

A regular expression is a sequence of characters defining a search pattern used to find, replace, or validate text. JavaScript relies on the ECMAScript RegExp engine, supporting modern features like Unicode properties and lookbehind assertions. If you are formatting variable lists to camelCase or kebab-case before matching them, convert them with our Case Converter. Here is how to create a regular expression in JS:
// Literal notation (compiled once when the script is loaded)
const literalRegex = /\b[A-Za-z]+\b/g;

// Constructor function (compiled at runtime, useful for dynamic inputs)
const dynamicRegex = new RegExp("\\b[A-Za-z]+\\b", "g");
  • Literal notation compiled at load time for fast performance
  • Constructor function compiles at runtime for dynamic input values
  • Full support for modern ECMAScript standard RegExp parameters
  • Performs execution entirely in local memory with zero server calls

Utilizing regex flags to control matching behavior

Flags are single-character modifiers appended to regular expressions that alter how the matching engine operates. Common flags include global search, case insensitivity, multiline matches, and unicode evaluation. If you are extracting encoded variables from test strings, you can verify their values using our Base64 Encoder / Decoder. Here are the common flags:
/* JavaScript RegExp Flag Parameters */
const regex = /pattern/gimsuy;
// g -> global (find all matches rather than stopping at the first)
// i -> case-insensitive (ignore upper/lower character differences)
// m -> multiline (makes ^ and $ match start/end of individual lines)
  • Global flag (g) preserves the lastIndex property to track matches
  • Dot All flag (s) allows the wild dot character to match newline breaks
  • Unicode flag (u) enables proper parsing of emoji characters and scripts
  • Sticky flag (y) matches strictly starting at the target index position

Capture groups and subpattern extraction

Parentheses define capture groups, which allow you to extract specific segments of a matched string. The matching engine remembers these subpatterns and returns them in a structured array. If you are converting tabular row outputs into structured databases, parse them using our CSV to JSON Converter. Here is how to extract capture group elements:
const logLine = "2026-06-02 [INFO] Server started";
const regex = /(\d{4}-\d{2}-\d{2})\s+\[([A-Z]+)\]/;
const match = regex.exec(logLine);

// match[0] -> "2026-06-02 [INFO]" (Full Match)
// match[1] -> "2026-06-02" (First Capture Group)
// match[2] -> "INFO" (Second Capture Group)
  • Enables developers to isolate substrings from complex data streams
  • Supports named capture groups (?<name>...) for clearer code maintenance
  • Provides numeric index arrays for quick indexing loops
  • Essential for string splitting and data extraction workflows

Lookahead and lookbehind assertions

Assertions are zero-width matches that check if a pattern is preceded or followed by another pattern, without including it in the match result. Lookbehinds allow you to check characters before the match, which is useful for validating currency codes or tag identifiers. If you need to analyze JWT header properties after finding them in text blocks, try our JWT Decoder. Here are lookbehind examples:
// Positive lookbehind (?<=): Match digits only if preceded by "$"
const priceRegex = /(?<=\$)\d+/;
"$100".match(priceRegex); // Matches "100"

// Negative lookbehind (?<!): Match digits only if not preceded by "$"
const numberRegex = /(?<!\$)\b\d+\b/;
"100 USD".match(numberRegex); // Matches "100"
  • Asserts positional requirements without consuming string index characters
  • Simplifies patterns by removing the need for post-processing splits
  • Supported natively in modern V8 browser engines
  • Allows parsing of nested tag attributes cleanly

Validating common inputs using regular expressions

Regular expressions are commonly used to validate inputs like emails, dates, and numbers. It is best to test validation patterns against multiple inputs before deploying them to production. If you are writing user guide documentation for these patterns, convert them with our Markdown to HTML Converter. Here are common validation patterns:
// Email address validation pattern
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;

// Numeric integer validation pattern
const integerRegex = /^-?\d+$/;

// Standard YYYY-MM-DD date validation pattern
const dateRegex = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
  • Validates input formats client-side to reduce backend processing loads
  • Forces structured guidelines for formatting string components
  • Supports character limits and numeric boundaries dynamically
  • Helps prevent SQL injection or bad inputs from entering database rows

Debugging catastrophic backtracking issues

Catastrophic backtracking occurs when a pattern containing nested quantifiers is run against non-matching strings, causing exponential evaluation steps. This can freeze browser tabs or crash servers. If you want to filter out duplicate rows or clean server log blocks before parsing them, try our Duplicate Line Remover. Here is an example of an insecure pattern:
// Insecure pattern vulnerable to backtracking
const badPattern = /^(a+)+$/;

// A long string of "aaaa...aab" causes exponential evaluations
badPattern.test("aaaaaaaaaaaaaaaaaaaaaaaaab");
  • Occurs when matching engines are forced to explore nested loop variations
  • Fixed by removing overlapping quantifiers or utilizing lookaheads
  • Tested locally using deferred inputs to prevent UI thread crashes
  • Essential optimization step for robust web application security

How to Use RegEx Tester

1

Enter your regex pattern in the input box

Type your search pattern in the top input box. You do not need to wrap the pattern in slashes.

2

Set your regex flags

Configure modifier flags (like g for global, i for case-insensitive, or m for multiline) using the flags input field.

3

Input text to test against

Paste your target code snippet, log data, or test paragraphs into the Test String panel.

4

Review matches and capture groups

Check the matches in the Highlight Preview panel. You can inspect the total match count and copy the matches list from the Matches Found card.

5

Resolve syntax errors instantly

If your pattern contains invalid parameters, the debugger displays an error message instantly to help you correct the syntax.

Sponsored

Common questions

What is a regex tester and debugger?

A regex tester is an online developer utility that parses regular expression patterns, highlights matches in a test string, and lists capture groups to simplify debugging.

Is my test data secure when using this online debugger?

Yes. Hashing and evaluation processes run completely in local memory. No strings, patterns, or logs are transmitted to external servers, ensuring complete privacy.

Which regular expression engine flavor does this tool use?

It uses the browser's native JavaScript (ECMAScript) regex engine, which is fully compatible with modern V8 runtimes, Node.js, and web browsers.

Does this tester support positive and negative lookbehind?

Yes, positive ((?<=...)) and negative ((?<!...)) lookbehinds are supported, as modern browsers fully support zero-width assertions.

What is the difference between global and non-global matching?

Without the global (g) flag, the engine stops after finding the first match. Enabling the global flag evaluates the entire string to extract all matching occurrences.

How do I create case-insensitive search patterns?

Add the case-insensitive flag (i) to match characters regardless of their upper or lower casing (e.g. matching [a-z] against capital letters).

How do I make the dot match newline characters?

Enable the dotAll flag (s) to allow the wildcard dot (.) character to match newline characters (\n or \r).

What is catastrophic backtracking and how do I prevent it?

Backtracking issues happen when overlapping quantifiers (e.g. (a+)+) force the engine to check too many path combinations on non-matching strings. Avoid nesting loops to prevent this.

How does the multiline flag affect start and end anchors?

The multiline (m) flag causes the start (^) and end ($) anchors to match the boundaries of each line within a text block, rather than the boundaries of the entire text string.

Can I extract specific parts of a match using capture groups?

Yes. Wrap patterns in parentheses (pattern) to define capture groups. The matching list displays these subpatterns separately, making it easy to extract substrings.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (like * or +) match as many characters as possible. Appending a question mark (like *? or +?) makes them lazy, matching as few characters as possible.

How do I match special characters like dots, slashes, or brackets?

Prepend a backslash (\) to escape reserved characters. For example, match a literal dot using \. and a literal backslash using \\.

Can this regex tester parse complex log file patterns?

Yes. You can paste raw log lines, write a matching pattern with capture groups, and verify that the correct parameters are parsed.

Does the tool support named capture groups?

Yes, you can use the standard (?<name>...) syntax to name capture groups, making matches easier to reference in your code.

How do I test regex patterns using keyboard shortcuts?

The tool processes strings instantly. You can copy the matches using the Ctrl + Shift + C shortcut, or clear the inputs using Ctrl + L.

Related tools

Deep Dives & Guides

Master this tool with our expert tutorials and best practices.