Skip to content

Regex Tester

Test regular expressions with real-time match highlighting, group capture display, and a pattern library.

Regex Tester tool

Loading...

Example

Input: Pattern \d{4}-\d{2}-\d{2} on the text: Invoices due 2024-03-15 and 2024-04-01.

Result: 2 matches: 2024-03-15 and 2024-04-01

With the global flag on, every date in YYYY-MM-DD form is found and highlighted. \d matches one digit and {4} repeats it four times.

Patterns in the Common Patterns Menu

Pattern nameRegex
Email address[\w.+-]+@[\w-]+\.[\w.]+
URLhttps?://[\w\-._~:/?#[\]@!$&'()*+,;=%]+
IPv4 address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
US phone number\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})
Date (YYYY-MM-DD)\d{4}[/-]\d{2}[/-]\d{2}
Hex color code#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b
US ZIP code\b\d{5}(-\d{4})?\b
HTML tags<[^>]+>
Numbers (int and float)-?\d+\.?\d*

Loaded exactly as listed. Adjust them to your data before using them for validation.

  1. Enter your regular expression pattern in the regex input field at the top.
  2. Toggle the desired flags (global, case-insensitive, multiline, etc.) using the flag buttons.
  3. Paste or type your test string in the text area below to see matches highlighted in real time.
  4. Review the match details panel showing matched text, capture groups, and index positions.
  5. Pick an entry from the Common Patterns menu to load a ready-made regex such as email or URL matching.
  6. Copy individual matches with their copy buttons, then use your finalized pattern in your application code.

Testing Regular Expressions in JavaScript

A regex tester shows exactly what a regular expression matches. Type a pattern and some sample text, and every match is highlighted as you type, with a count, the position of each match and what each capture group caught.

A regular expression (regex) is a small pattern language for finding text. \d{4} means four digits in a row, and [a-z]+ means one or more lowercase letters. Patterns get hard to read fast, so testing them on real samples, including text that should not match, is the quickest way to find mistakes.

The tool uses your browser's own JavaScript RegExp engine, so results match what you get in JavaScript, TypeScript and Node.js.

Four flags can be switched on or off. The g flag (global) finds every match and is on by default. The i flag ignores case, m (multiline) lets ^ and $ match at each line, and s (dotAll) lets . match line breaks. With g off, only the first match is shown. To keep the page responsive, a run stops at 1,000 matches.

The Common Patterns menu loads ready-made patterns, listed in the table below. Treat them as starting points rather than strict validators. The email pattern, for instance, accepts some addresses a mail server would reject. If a pattern has a syntax error, the engine's message is shown. For a guided tour of the syntax, open the Regex Cheatsheet. To apply a pattern to text, try Find and Replace.

Sources

Frequently Asked Questions

It uses the JavaScript (ECMAScript) engine built into your browser. The basics work the same in Python, Java, PHP and .NET, but details differ. Python writes named groups as (?P<name>...) while JavaScript uses (?<name>...), and features like possessive quantifiers (a++) and atomic groups are not available in JavaScript at all.
No. Type only the pattern itself, such as \d+, without the surrounding /.../ and without flags. Set flags with the toggles. Also type a single backslash here. Inside a JavaScript or Java string literal you would need to double it, as in "\\d+", but this box takes the pattern as is.
The Match Details list shows every match with its index, the character position where it starts. Under each match you see Group 1, Group 2 and so on, in the order their opening brackets appear in the pattern. Named groups also work and are listed by their number. Each match has its own copy button.
Patterns that can match nothing, such as \d* or a lone ^, succeed at positions where there is no text to take. The tester records those zero-length matches and moves on one character, so you may see many of them. Use + instead of * when you need at least one character.
The global (g) flag is off. Without it, a JavaScript regex stops after the first match, and the tester shows exactly that. Switch g back on to find every match in the text.
Check three things. In a string literal, backslashes usually must be doubled, so d becomes "\d". Flags are set separately in code, for example /abc/gi in JavaScript or re.IGNORECASE in Python. And other engines differ in details, such as lookbehind support. Copy the pattern into your code, then test it once in the target language.

Related Tools

Find and Replace

Find and replace text with regular expressions, capture groups, case-sensitive matching, and a live match count.

Text and Writing

JSON Formatter and Validator

Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.

Developer Tools

Regex Cheatsheet

Interactive regex syntax reference with descriptions, examples, and a try-it-live tester for each pattern.

DevOps Tools

URL Encode and Decode

Encode special characters for URLs or decode percent-encoded strings back to readable text.

Developer Tools

Word Counter and Character Counter

Count words, characters, sentences, and paragraphs in your text. Includes reading time and speaking time estimates.

Text and Writing

Case Converter

Convert text between UPPER, lower, Title, Sentence, camelCase, snake_case, kebab-case, CONSTANT_CASE, and PascalCase.

Text and Writing