Regex Tester Online — Test Regular Expressions
Test and debug your regular expressions in real-time. Matches are highlighted instantly in your text. Capture groups, configurable flags and built-in cheat sheet. JavaScript engine — free, no sign-up.
🔒 Your data never leaves your browser
100% secure
Your files are never shared
Ultra-fast
Processing in seconds
Privacy
Automatic deletion after 1h
How to test regular expressions
Enter your regex
Type your regular expression pattern in the input field. Select flags (g, i, m, s) using the checkboxes next to it.
Paste your test text
Enter the text you want to test against in the large text area. Matching portions are highlighted in real-time as you type.
Review matches
The results panel shows the number of matches, each match with its capture groups, and the start/end positions. Modify your regex to refine the results.
Regex basics
Regular expressions use literal characters and metacharacters. Literal characters match themselves (abc matches "abc"). Metacharacters have special meaning: . matches any character, * means zero or more, + means one or more, ? means zero or one, ^ matches start of string, $ matches end of string.
The pipe | means OR (cat|dog matches "cat" or "dog"). Parentheses () create groups and capture matches. Square brackets [] define character classes ([aeiou] matches any vowel).
Quantifiers: greedy vs lazy
By default, quantifiers are greedy — they match as much text as possible. The pattern .* in "‹b›hello‹/b›" matches "‹b›hello‹/b›" (the entire string between the first ‹ and last ›).
Adding ? makes a quantifier lazy — it matches as little as possible. The pattern .*? in the same string matches just "‹b›" (stops at the first ›). This is crucial when parsing structured text like HTML or JSON.
Character classes
Built-in classes: \d matches any digit (0-9), \w matches word characters (letters, digits, underscore), \s matches whitespace (space, tab, newline). Uppercase versions (\D, \W, \S) match the opposite.
Custom classes use brackets: [a-z] matches lowercase letters, [^0-9] matches anything except digits, [A-Za-z0-9_] is equivalent to \w. Ranges work for consecutive Unicode code points.
Capture groups and backreferences
Parentheses () create capture groups that extract specific parts of a match. In the pattern (\d{4})-(\d{2})-(\d{2}), group 1 captures the year, group 2 the month, group 3 the day.
Non-capturing groups (?:...) group without capturing — useful for applying quantifiers to a group without creating an extra capture. Named groups (?‹name›...) make captures more readable in code.
Lookahead and lookbehind
Lookahead (?=...) matches a position followed by a pattern without consuming it. For example, \d+(?= dollars) matches digits only when followed by " dollars". Negative lookahead (?!...) matches when NOT followed by the pattern.
Lookbehind (?<=...) matches a position preceded by a pattern. (?<=\$)\d+ matches digits preceded by $. JavaScript supports both lookahead and lookbehind in modern engines.
Useful common patterns
Email validation: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. URL extraction: https?://[\S]+. Phone numbers: \+?\d[\d\s-]{7,}\d. IPv4 address: \d{1,3}(\.\d{1,3}){3}.
Remember that these patterns are simplified for common cases. Production-grade validation often requires more specific patterns or purpose-built parsers. A regex that''s "good enough" is often better than a perfect one that''s unreadable.
Common pitfalls
Catastrophic backtracking occurs when a regex has nested quantifiers that create exponential matching paths. Patterns like (a+)+ or (a|a)* on long inputs can freeze your browser. This tool includes a timeout to protect against this.
Engine differences are another trap: JavaScript's regex engine differs from PCRE (PHP), Python's re module, and .NET's System.Text.RegularExpressions. Features like possessive quantifiers (a++), atomic groups ((?>...)), and conditional patterns are not available in JavaScript.
Regex Tester Online — Test Regular Expressions — Frequently asked questions
What is a regular expression (regex)?
A regular expression is a search pattern that describes a set of character strings. Regex are used to search, validate and extract data from text. For example, the pattern \d{3}-\d{4} matches a format like "555-1234".
Which regex engine is used?
The tool uses the native JavaScript regex engine (ECMAScript). It is the same engine as your browser, Node.js and many web tools. Syntax specific to other languages (variable lookbehind in PCRE, possessive quantifiers) may not be supported.
Is my data sent to a server?
No. Regex testing happens entirely in your browser. Your text and expressions never leave your device.
What do the flags g, i, m and s mean?
g (global): finds all matches, not just the first. i (case-insensitive): ignores case. m (multiline): ^ and $ match the start/end of each line. s (dotAll): the dot (.) also matches newline characters.
My regex seems correct but doesn't match anything, why?
The most common causes: you forgot the g flag to find multiple matches, special characters are not escaped (a dot . matches everything, use \. for a literal dot), or the regex is case-sensitive and your text has different casing.
Is the tool suitable for learning regex?
Yes. Real-time highlighting and capture group display let you immediately see the effect of each change. The built-in cheat sheet reminds you of common patterns. For deeper learning, we recommend combining this tool with regex tutorials.
Similar tools
JSON Formatter
Format, validate and minify JSON online
Base64 Encode/Decode
Encode and decode text and images in Base64
URL Encode/Decode
Encode and decode URLs and query parameters
Unix Timestamp Converter
Convert Unix timestamps to readable dates
Password Generator
Generate strong, secure passwords
Lorem Ipsum Generator
Generate placeholder text for your designs