Developer tool

100% In-Browser

Regex Tester

Test JavaScript regular expressions against text, inspect highlighted matches and numbered capture groups, and copy matched values. Everything runs in your browser while you experiment with patterns, flags, and sample input.

//g
Regular expression flags

Characters

158

Words

22

Lines

3

Matches

Results

8 matches

Ada Lovelace wrote notes on the Analytical Engine. Grace Hopper helped popularize the term debugging. Katherine Johnson calculated orbital mechanics for NASA.

Match Details

Adaindex 0
Lovelaceindex 4
Analyticalindex 32
Engineindex 43
Graceindex 51
Hopperindex 57
Katherineindex 102
Johnsonindex 112
Enter a pattern to test it against your text.

Overview

What Is a Regex Tester?

A regular-expression tester lets developers, students, data analysts, writers, and technical teams check how a pattern matches a piece of text. Enter a JavaScript pattern, select flags, and use the highlighted result, match indices, and capture groups to understand the output before using the expression in code.

This page is a practical JavaScript RegExp workspace, not a universal regex flavor converter. Regular-expression syntax can differ across languages and tools, so test patterns again in the same runtime where they will be deployed.

Features

Regex Tester Features

Pattern input

Enter a JavaScript pattern without surrounding slash delimiters.

Available flags

Toggle g, i, m, s, u, and y from the provided controls.

Every match

The tester iterates with a global RegExp internally to show all matches.

Highlighted text

See matched text highlighted within the entered test text.

Match details

Inspect each matched value and its zero-based index.

Capture groups

Review numbered parenthesized capture values for each result.

Text statistics

See character, word, and line counts for the test text.

Copy and sample controls

Copy match values, clear the workspace, or restore the provided sample.

Flags

Supported JavaScript Regex Flags

FlagControl labelBehavior relevant to this tester
gGlobalIncluded in the displayed flags; the result loop uses global iteration whether or not it is selected.
iIgnore caseMakes matching case-insensitive.
mMultilineChanges start and end anchor behavior around line terminators.
sDot allMakes dot match line terminators.
uUnicodeEnables JavaScript Unicode-aware regex features.
yStickyRequires a match at the current lastIndex position during iteration.

Method

How the Regex Tester Works

When both a nonblank pattern and test text are present, the tool creates new RegExp(pattern, flags). It adds the global flag internally when it is not selected, then calls exec() repeatedly to build highlighted segments, values, indices, and capture-group arrays. For zero-length matches, it increments lastIndex by one to avoid an endless loop.

The visible pattern suffix reflects only your selected controls. Empty inputs display no matches, and construction errors are reported in the result panel. The interface does not expose replacement, named-group labels, match indices from the d flag, the v flag, saved expressions, file input, or server-side testing.

Workflow

How to Use the Regex Tester

  1. Enter a JavaScript regex pattern without outer slash characters.
  2. Toggle any supported flags needed for the test.
  3. Paste or type the text to search.
  4. Review highlighted matches, zero-based indices, and numbered capture groups.
  5. Copy the matched values, or Clear and Load Sample to begin again.
  6. Test the final expression in the target JavaScript runtime before deployment.

Examples

Common Uses

Input checking

Inspect an email-like, identifier-like, or reference-number pattern before adding application-specific validation.

Text extraction

Use parentheses to see captured portions of a structured log line or paragraph.

Content cleanup planning

Find repeated spacing, markers, or formatting fragments before handling them elsewhere.

Learning JavaScript regex

Compare the effect of multiline, dotAll, or sticky mode against a short sample.

Debugging

Confirm the match position and captures of a pattern that behaves unexpectedly in a JavaScript project.

Advantages

Benefits

  • Provides immediate visual feedback for JavaScript regular expressions.
  • Shows each value, position, and numbered capture group in one workspace.
  • Keeps input text and matching in the browser.
  • Offers common JavaScript flag controls without extra dependencies.
  • Makes match values easy to copy for another workflow.

Boundaries

Limitations

  • Patterns follow the browser JavaScript engine, not PCRE, Python, .NET, Java, or another regex flavor.
  • Every-match display adds global iteration internally, even when g is not selected.
  • Sticky matching can stop at the first position that does not match.
  • Named capture-group labels, replacement output, files, and saved expressions are not implemented.
  • Regex alone is not a security, sanitization, or complete data-validation strategy.

Guidance

Tips for Better Regex Tests

  • Start with a small representative example, then add edge cases.
  • Use parentheses when you need to inspect capture groups.
  • Test start and end anchors with and without multiline mode.
  • Use dotAll only when a dot should span line terminators.
  • Check the final expression in the exact JavaScript environment that will run it.

Avoid

Common Mistakes

  • Pasting outer slash delimiters into the pattern field.
  • Assuming a pattern from another programming language follows JavaScript syntax.
  • Expecting the visible g control to limit results to one match when the tester lists all matches.
  • Confusing multiline anchors with dotAll behavior.
  • Using a regex tester as proof that input is secure or fully validated.

Questions

FAQ

What is a regex tester?

A regex tester applies a regular-expression pattern to supplied text and shows matching text, positions, and available capture groups.

Which regular-expression flavor does this tool use?

It uses the JavaScript RegExp constructor in the browser, so pattern syntax and errors follow the JavaScript engine available in that browser.

Which flags can I choose?

The interface provides global (g), ignore case (i), multiline (m), dotAll (s), Unicode (u), and sticky (y) flags.

Why does the tool show all matches when Global is off?

The tester adds g internally when needed so it can iterate through and display every match. The selected flags shown beside the pattern remain the ones you chose.

What does the Global flag do here?

The g flag is selected by default and makes the displayed pattern include global matching. The result loop also ensures global iteration for its match list.

What does Ignore case do?

The i flag makes the JavaScript regular expression attempt matching without case sensitivity according to the engine's rules.

What does Multiline do?

The m flag changes how start and end anchors behave around line terminators. It does not make a dot match newline characters.

What does Dot all do?

The s flag makes a dot match line terminators as well as other characters.

What does Unicode do?

The u flag enables JavaScript Unicode-aware regular-expression features. Exact behavior still depends on the pattern and browser implementation.

What does Sticky do?

The y flag requires a match at the current lastIndex position. Because this tester starts at the beginning and iterates, a sticky pattern stops when it cannot match exactly at the next position.

Are capture groups displayed?

Yes. Parenthesized captures returned by the JavaScript match result appear as numbered group values below each match. Named group labels are not displayed by this interface.

Can I replace text with this tool?

No. The implementation tests and highlights matches, lists capture groups, and copies matched values. It does not include a replacement field or replacement output.

What happens when my pattern is invalid?

The browser's RegExp construction error is displayed in the results panel and no matches are listed.

Does it work on mobile devices?

Yes. The tester uses standard browser inputs, text areas, buttons, and scrollable result details.

Is my pattern or text uploaded to a server?

The tester runs in the browser and does not intentionally upload your entered pattern or test text.

Is the Regex Tester free?

Yes. It is a free browser-based JavaScript regular-expression testing tool.

Terms

Glossary

Regular expression

A pattern used to match text.

Pattern

The regular-expression source entered into this tool.

Match

The portion of text returned by a successful pattern search.

Capture group

A parenthesized part of a pattern whose matched text is returned separately.

Index

The zero-based character position at which a match begins.

Flag

A modifier that changes matching behavior.

Global

A flag used for repeated matching across text.

Multiline

A flag that changes the behavior of start and end anchors at line boundaries.

DotAll

A flag that lets a dot match line terminators.

Unicode

A JavaScript regex mode that enables Unicode-aware features.

Sticky

A mode that requires matching exactly at lastIndex.

lastIndex

The RegExp position used as the starting point for a subsequent global or sticky match.

Transparency & Verification

Educational Disclaimer

100% In-Browser Execution

This tool evaluates patterns with the browser's JavaScript RegExp implementation and shows its implemented match details. Results can differ across regex flavors and browser versions. It is intended for development, learning, debugging, and text-analysis workflows, not as a substitute for security review or complete application validation.

Calculations and transformations execute locally on your machine with full offline support. Always verify critical results.

View full legal disclaimer