I would actually use a named pattern here. Something like `'|\\$(?<replacementKey>\d)|'`. Than you can access it with  `$m['replacementKey']`.