String Replace Tool
Test regex-based string replacement with multiple examples and see real-time results.
How to Use This Tool
This tool helps you understand and test regex-based string replacement. Perfect for learning how to use the replace() method with regular expressions.
- Enter the text you want to modify
- Specify the regex pattern to match
- Enter the replacement string (can use $1, $2, etc. for captured groups)
- See the results in real-time
Quick Examples
//
Replacement Reference
Capture Group References
- $1, $2, $3... - Refer to captured groups
- $& - The entire matched substring
- $` - The text before the match
- $' - The text after the match
Common Examples
- Swap names: (.*) (.*) → $2 $1
- Add prefix: (.*) → Prefix: $1
- Email masking: (.*)@(.*) → $1***@***$2
🔥
Popular Patterns
📧
Email Address
Validate standard email formats. Includes support for common domains and subdomains.
Try Email Regex →📅
Dates (YYYY-MM-DD)
Match dates in ISO 8601 format. Validates year, month, and day structure.
Try Date Regex →📱
US Phone Number
Match various US phone formats including dashes, dots, and parentheses.
Try Phone Regex →