'Sublime Text 3 - Regex find/replace first captured group with second captured group?
I have two XML files I'm editing using Sublime Text 3. The first file acts as a template, while the second file is based on data export that is a batched XML file with multiple references to the targeted tags. I am looking to extract all found references and paste them into the placeholder in my template.
I'm using the Find in files option to find both my replacement text placeholder (i.e. <--Replacement XML-->) in my template, along with the XML that should replace it in the secondary file (...):
((<!--Replacement XML-->)|((?s)<activities>\s*\K(.*?)(?=\s*</activities>)))
The capturing groups work fine to both target both capturing groups, but I'm wondering if it's possible to use the replace feature to replace "<--Replacement XML-->" with the results found using the second capturing group.
I've seen references to identifying the capture group using the sequence of the capturing group (ex: $1 or \1), but it doesn't seem to work and instead tries to replace all references rather than my placeholder.
Sample taken from files:
Template:
<placeholder>
<!--Replacement XML-->
</placeholder>
Bulk Data
<activities>
<part>Some String</part>
<part>Some Other String</part>
</activities>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
