.*
Regex Tool

Regex Tester

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

/g
JavaScript Regex Flagsgi

Test Text Input for Regex Matching

73 chars
Input Editor

Regex Match Results

2 matches

2 matches found.

JavaScript regex learning guide

Online JavaScript Regex Tester and Regular Expression Checker

Use this regex expression online tool to test JavaScript regex patterns against real text. It helps you validate search patterns, debug capture groups, understand match indexes, and compare how regex flags change matching behavior.

What is a regex pattern?

A pattern describes what text you want to find. For example, \d+ finds one or more digits, \bcat\b finds the separate word cat, and ^[A-Za-z]+$ validates letters only.

What are regex flags?

Flags change how JavaScript evaluates the pattern. Use g for all matches, i for case-insensitive matching, m for multiline anchors, and s when dot should match line breaks.

What are capture groups?

Parentheses capture part of a match. A pattern like (GET|POST)\s+(/[\\w/-]+) captures the HTTP method and path separately, which is helpful for logs, routes, and structured text.

Privacy note

Regex testing runs inside your browser. Avoid pasting passwords, private tokens, or confidential data into any online tool, even when processing is browser-based.

JavaScript Regex Examples

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/i;
const hasEmail = emailRegex.test("[email protected]");
const logRegex = /(GET|POST)\s+(\/[\w/-]+)\s+(\d{3})/g;
const matches = [...text.matchAll(logRegex)];

Common Regex Patterns

  • ^\d+$Only numbers
  • ^[6-9]\d{9}$Indian mobile number
  • ^[1-9][0-9]{5}$Indian PIN code
  • ^https?:\/\/[^\s]+$Basic URL format

Regex help center

Regex Tester FAQ

What is a regular expression?

A regular expression, commonly called regex, is a pattern used to search, match, validate, replace, or extract text.

What does this JavaScript Regex Tester do?

This JavaScript Regex Tester lets you enter a regular expression and test it against sample text. It displays matched text, match indexes, capture groups, and useful details.

How do I test a regular expression?

Enter your regex pattern, select any required flags, and paste the text you want to test. The tool lists the matching results instantly.

Should I include forward slashes in the regex pattern?

Usually, enter only the regex pattern without opening and closing forward slashes. For example, enter \d+ instead of /\d+/. Use the flags field separately.

What are regex flags in JavaScript?

Regex flags change how a pattern is evaluated. Common JavaScript flags include g, i, m, s, u, y, and d.

What does the global flag g do?

The g flag finds all matches in the input text instead of stopping after the first match.

What does the case-insensitive flag i do?

The i flag makes matching case-insensitive, so apple can match Apple, APPLE, or apple.

What does the multiline flag m do?

The m flag changes ^ and $ so they can match the beginning and end of each line.

What does the dotAll flag s do?

The s flag allows the dot character to match newline characters.

What does the Unicode flag u do?

The u flag enables improved Unicode handling for emojis, international characters, code points, and property escapes.

What is a regex match index?

A match index is the zero-based position where a match begins in the input text.

What are capture groups in regex?

Capture groups are parts of a regex pattern inside parentheses. They capture sections of matched text for inspection or reuse.

What are named capture groups?

Named capture groups assign readable names to captured values. JavaScript uses the syntax (?<name>pattern).

What do ^ and $ mean?

^ normally matches the beginning of input and $ matches the end. They are commonly used for full-value validation.

What do *, +, and ? mean in regex?

* means zero or more occurrences, + means one or more, and ? means zero or one occurrence.

How can I match an email address?

A basic email pattern is ^[^\s@]+@[^\s@]+\.[^\s@]+$. Email validation can be complex, so regex alone does not prove that an address exists.

How can I match an Indian mobile number?

A basic pattern for a 10-digit Indian mobile number is ^[6-9]\d{9}$.

How can I match only numbers?

Use ^\d+$ to match one or more digits and reject all other characters.

Why is my regex returning only one match?

JavaScript returns one match unless global matching is enabled. Add the g flag to find every matching occurrence.

Why is my regex matching more text than expected?

The pattern may contain a greedy quantifier such as .* or .+. Use a lazy version like .*? or a more specific character class.

Why is my regex not matching line breaks?

Dot does not match newline characters by default. Use the s flag or a pattern such as [\s\S].

What is catastrophic backtracking?

Catastrophic backtracking happens when a poorly designed regex forces the engine to test many combinations, making matching very slow.

Is this JavaScript Regex Tester safe to use?

The tool runs in your browser, but avoid pasting passwords, private keys, tokens, confidential documents, or sensitive records into any online testing tool.

Can I use the tested regex in my JavaScript project?

Yes. After testing, use it as a regex literal or with the RegExp constructor, making sure flags and escaping are correct.

Suggested tools

Continue with related browser utilities

View sitemap ->