Regex Tester

Test JavaScript regular expressions in real time. Matches are highlighted inline. Supports global, case-insensitive, multiline, and dotAll flags.

Regular Expression

//g
Examples:

Test String

Match Preview

Contact us at support@example.com or sales@company.org.
Visit https://devtoolshub.dev for more tools.
Server IP: 192.168.1.100. Color: #ff6347.

FAQ

Which regex flavor does this use?

This tool uses JavaScript (ECMAScript) regular expressions via the built-in RegExp engine. Most patterns are compatible with JavaScript, Python, and other languages, but some advanced features like lookbehinds may differ.

Why does my match loop infinitely?

Zero-length matches with the global flag can cause infinite loops. This tool automatically advances lastIndex when a zero-length match is found to prevent this.

What does the 's' (dotAll) flag do?

Without the dotAll flag, the . metacharacter does not match newline characters. The s flag makes . match any character including \n.

Frequently Asked Questions

Which regex flavor does this tool use?

JavaScript (ECMAScript) regular expressions — the same engine used in Node.js and all modern browsers. Supports ES2018+ features including named capture groups and the s (dotAll) flag.

What does the g flag do?

The g (global) flag makes the regex find all matches in the string instead of stopping after the first match. Essential for replace-all operations and counting total occurrences.

What are capture groups?

Capture groups, created with parentheses ( ), let you extract specific parts of a match. Named groups (?<name>...) give each group a descriptive label accessible via match.groups.name.

What is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. They are used to find, validate, extract, or replace text that matches the pattern. Regex is supported natively in JavaScript, Python, Java, Go, Ruby, Rust, PHP, and most other programming languages.

Common use cases include: validating email addresses, phone numbers, and postal codes; extracting data from logs; replacing text in bulk; parsing structured data like URLs or markdown; and building lexers and parsers.

Quick Regex Reference

PatternMeaningExample match
.Any character except newlinea, b, 1, @
\dDigit (0–9)0, 5, 9
\wWord char (letter, digit, _)a, Z, 3, _
\sWhitespace (space, tab, newline) , \t
^Start of stringFirst char
$End of stringLast char
*0 or more of previousaaa, a, ""
+1 or more of previousaaa, a (not empty)
?0 or 1 of previous (optional)colour / color
{n,m}Between n and m repetitions{2,4} → aa, aaa
[abc]Any one of a, b, ca, b or c
[^abc]Any character except a, b, cd, e, 1
(abc)Capture groupextracts 'abc'
(?:abc)Non-capturing groupgroups without capture
(?<n>abc)Named capture groupmatch.groups.n
a|bAlternation (a or b)a or b

JavaScript Regex Flags

  • g — global

    Find all matches, not just the first one. Required for replace-all and counting total occurrences.

  • i — case-insensitive

    Match regardless of letter case. /hello/i matches 'Hello', 'HELLO', 'hElLo'.

  • m — multiline

    ^ and $ match the start/end of each line instead of the whole string.

  • s — dotAll

    Makes . match newline characters too. Without s, a dot skips line breaks.

  • u — unicode

    Enables full Unicode support. Required for matching emoji and non-BMP code points correctly.