Regexray
Test a regular expression against your own text. Every match, every group, and what a replacement would produce.
The matching happens on your own machine, so nothing you paste is sent anywhere.
Matches
The pattern, drawn
Step by step
The engine tries to match from each position in turn, and keeps going after each match to find the next. Every box is a part of your pattern, and it says where the engine was and what that part took from your text. A line pointing back is the engine giving text back and trying again.
Use $1 for the first group, $0 for the whole match, and
$$ for a dollar sign.