Find and wrap all instances of a certain regex search at once
Posted: Sun Apr 04, 2021 9:41 pm
I have a document which I need to find and wrap all instances inside brackets with a tag and keep the content inside the brackets. For instances. I have [1], [13, 14], [22] etc. in my document and I need to find using regex which I use \[.*?\] and then replace with
[<xref ref-type="aff" rid="R1">1</xref>]
[<xref ref-type="aff" rid="R13">13</xref>, <xref ref-type="aff" rid="R14">14</xref>]
etc.
Is there a way to do this all at once. Essentially finding and keeping the numbers I find and replace with a tag and use that number inside the tag.
[<xref ref-type="aff" rid="R1">1</xref>]
[<xref ref-type="aff" rid="R13">13</xref>, <xref ref-type="aff" rid="R14">14</xref>]
etc.
Is there a way to do this all at once. Essentially finding and keeping the numbers I find and replace with a tag and use that number inside the tag.