Test regular expressions in real-time. See matches highlighted, extract groups, replace and explore a full cheatsheet.
Regular Expression Tester
A regular expression (regex or regexp) is a sequence of characters defining a search pattern. Used in virtually every programming language, regex is essential for text processing, validation, parsing and transformation.
Regex flags explained
- g (global) — Find all matches, not just the first
- i (case insensitive) — Match regardless of case
- m (multiline) — ^ and $ match start/end of each line
- s (dotAll) — . matches newline characters too
Frequently Asked Questions
What does .* mean in regex? +
. matches any character (except newline by default), and * means "zero or more" of the preceding element. So .* matches any sequence of characters. It's greedy — it will match as much as possible. Use .*? for lazy matching (as little as possible).
How do I match a literal dot or special character? +
Escape it with a backslash. To match a literal dot use \., a literal + use \+, a literal ( use \(, etc. Special characters that need escaping: . * + ? ^ $ { } [ ] | ( ) \
What is a capture group and how do I use $1? +
Parentheses create a capture group: (pattern). Each group gets a number starting at 1. In replacement strings, $1 refers to the first group's match. For example, pattern (\w+) (\w+) with replacement $2 $1 would swap two words.
Is this JavaScript regex or PCRE? +
This tester uses JavaScript's built-in RegExp engine. JS regex is mostly compatible with other flavours but has some differences from PCRE (PHP/Python). Notably, JS supports lookbehind (?<=) in modern browsers, but doesn't support PCRE-specific features like \K or recursive patterns.