loot.tools

Regex Playground

Test regular expressions against sample text with instant results, then run a regex replace with $1 capture-group backreferences. Iterate on patterns before using them in code.

Enter a regex pattern and test string. Use flags: g global, i ignore case, m multiline.

Pattern & text
Matches

0 matches

Replace

What is regex?

Regular expressions (regex) are patterns that match character combinations in strings. Every major programming language and text editor supports them. A regex like \d{3}-\d{4} matches phone number fragments, and [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} matches email addresses. They're concise but tricky to get right, so a playground helps you iterate before committing to code.

How to use this playground

Enter your regex pattern in the pattern field and paste sample text below. Matches list out instantly as you type. Adjust flags (global, case-insensitive, multiline) to change matching behavior. To rewrite text, type a replacement string in the Replace field and reference capture groups with $1, $2, and so on. Use it to iterate on your pattern until it matches exactly what you want before putting it in code.

Tips for writing regex

Start simple and build up. Use \d for digits, \w for word characters, \s for whitespace. Use + for one or more, * for zero or more, ? for optional. Parentheses create capture groups. Square brackets define character classes. The dot matches any character except newline. When something isn't matching, check your flags - forgetting the global flag is a common mistake.