Revised regex-substitution-capturing logic - refs #70

Reworked the regexes to return to the original semantics
while still not using $1-style variables.