Implement BRE back-references correctly.