Clean up inreplace regexps

 - use literal syntax
 - escape interpolated variables
 - remove intermediate variables
 - remove unnecessary capture