Test regular expressions with real-time highlighting.
Type a regex pattern in the pattern box and test text below it — matches are highlighted in real time as you type. The Captured Groups table shows each match with its group values. All processing runs in your browser; nothing is sent to any server.
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regex is used in virtually every programming language for string searching, validation, parsing, and replacement. The JavaScript engine (ECMAScript) used here follows the same rules as new RegExp(pattern, flags) in the browser.
g — globalg, only the first match is returned.i — case-insensitive/hello/i matches "Hello", "HELLO", "hElLo".m — multiline^ and $ match the start and end of each line rather than the entire string.s — dotAll. metacharacter matches any character including newline (\n). Without s, . does not match newlines.\d Digit 0–9
\w Word character (letter, digit, underscore)
\s Whitespace (space, tab, newline)
\b Word boundary
. Any character except newline (with /s flag: including newline)
^ Start of string (with /m: start of line)
$ End of string (with /m: end of line)
* 0 or more (greedy)
+ 1 or more (greedy)
? 0 or 1 (or makes * + ? lazy)
{n,m} Between n and m times
(abc) Capturing group
(?:abc) Non-capturing group
[a-z] Character class
[^a-z] Negated character class
Email: ^[\w.-]+@[\w.-]+\.\w{2,}$
URL: https?://[\w./-]+
Date: \d{4}-\d{2}-\d{2}
IPv4: \b(?:\d{1,3}\.){3}\d{1,3}\b
Hex color: #[0-9a-fA-F]{3,6}
const pattern = /(\w+)@(\w+\.\w+)/g; const text = 'Contact [email protected] or [email protected]'; let match; while ((match = pattern.exec(text)) !== null) { console.log(`Full: ${match[0]}, User: ${match[1]}, Domain: ${match[2]}`); } // Replace all emails const redacted = text.replace(pattern, '[REDACTED]');
import re pattern = r'(\w+)@(\w+\.\w+)' text = 'Contact [email protected] or [email protected]' for match in re.finditer(pattern, text): print(f"Full: {match.group(0)}, User: {match.group(1)}")
RegExp (ECMAScript). Results will match what you get in Node.js and all modern browsers.. * + ? ^ $ { } [ ] | ( ) \*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, /<.+>/ on <a>text</a> matches the whole string (greedy), while /<.+?>/ matches just <a>.() create capturing groups. In JavaScript, match[1], match[2] etc. access them. Use (?:) for a non-capturing group when you only need grouping for quantifiers or alternation.