s/$a/$b/ # $a matches and is replaced by $b s/($a)/$1$b/ # $a matches and is captured in $1 # $b is appended