Regex Tester
Test regular expressions with live match highlighting, group capture, and find & replace — all in your browser.
Enter a pattern and test string to see matches
Quick Regex Reference
.
Any char (except newline)\d
Digit [0-9]\w
Word char [a-zA-Z0-9_]\s
Whitespace^
Start of string$
End of string*
0 or more+
1 or more?
0 or 1 (optional){n,m}
Between n and m times[abc]
Character class[^abc]
Negated class(abc)
Capture group(?:abc)
Non-capture groupa|b
Alternation (a or b)\b
Word boundary(?=...)
Lookahead(?<=...)
Lookbehind\1
Backreference to group 1$1
Replace with group 1About the Regex Tester
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Used in programming, text editors, and command-line tools, regex allows you to search, match, extract, and transform text with incredible precision.
This online regex tester lets you write and test regular expressions instantly with live highlighting. Enter your pattern, adjust flags (global, case-insensitive, multiline, dotall), and see matches highlighted in real time. Use the Replace field to test substitutions with $1, $2 group references.
Regex Flags Explained
-
gglobalFind ALL matches. Without g, only the first match is returned. -
icase insensitiveMatch both uppercase and lowercase. /hello/i matches "Hello", "HELLO", and "hello". -
mmultiline^ and $ match the start and end of each line, not just the whole string. -
sdotallMakes . match newline characters (\n) in addition to all other characters.
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a string of characters that defines a search pattern. It is used in programming languages, text editors, search tools, and databases to find, match, extract, validate, or replace text. Regex is supported in virtually every programming language including Python, JavaScript, Java, PHP, Go, Ruby, and more.
What does the "g" flag do in regex?
The "g" (global) flag tells the regex engine to find all matches in the string, not just the first one. Without "g", the regex stops after the first match. When using replace() in JavaScript, you need the "g" flag to replace all occurrences — without it, only the first match is replaced.
What is the difference between () and (?:) in regex?
() creates a capturing group that saves the matched text for later use via backreferences ($1, $2…) or group access. (?:) creates a non-capturing group — it groups the pattern for quantifiers or alternation but does not save the match. Use non-capturing groups when you don't need the captured text, for slightly better performance.
What does \b mean in regex?
\b is a word boundary assertion. It matches the position between a word character (\w) and a non-word character. For example, /\bcat\b/ matches "cat" in "the cat sat" but not "cats" or "concatenate". Word boundaries are useful for matching whole words without using spaces.
How do I match a literal dot (.) in regex?
In regex, . is a special metacharacter that matches any character except newline. To match a literal period, you must escape it with a backslash: \. For example, /3\.14/ matches "3.14" but not "3X14". Similarly, to match other metacharacters literally, prefix them with \: \*, \+, \?, \[, \], \(, \), \{, \}, \^, \$, \|, \\
What are lookahead and lookbehind?
Lookahead (?=...) matches a position followed by the pattern without including it in the match. Lookbehind (?<=...) matches a position preceded by the pattern. For example, /\d+(?= dollars)/ matches the number in "100 dollars" but the match is just "100", not "100 dollars". They are zero-width assertions — they check context without consuming characters.