Regex Tester

Test and debug regular expressions in real-time. See matches highlighted, view capture groups, and test replacements.

//g

Replace

Common Patterns

What are Regular Expressions?

Regular expressions (regex or regexp) are patterns used to match character combinations in strings. They are powerful tools for searching, validating, and manipulating text.

Common Regex Metacharacters

CharacterDescriptionExample
.Any charactera.c → abc, aXc
*0 or moreab* → a, ab, abb
+1 or moreab+ → ab, abb
?0 or 1colou?r → color, colour
^Start of line^Hello
$End of lineworld$
\dDigit\d+ → 123
\wWord character\w+ → hello_123
\sWhitespacehello\sworld
[abc]Character class[aeiou]
()Capture group(ab)+
|Orcat|dog

Regex Flags

  • g (global): Find all matches instead of stopping at the first
  • i (case-insensitive): Ignore uppercase/lowercase differences
  • m (multiline): ^ and $ match start/end of each line
  • s (dotall): Dot (.) matches newlines too

Tips for Writing Regex

  • Start simple and add complexity gradually
  • Escape special characters with backslash: \. \* \?
  • Use non-greedy quantifiers (*?, +?) when needed
  • Test with edge cases and unexpected input

Related Tools