I’d like to create a macro that will wrap numbers of the type ‘n’ and ‘n.m’ with numbered tags of the type <x/l> (where ‘l’ is a placeholder for a number).
I’ll place the string on the clipboard and I could do some Finding and replacing with regular expressions. But how do I get the numbers 'l’in the tags?
So there are really two problems here, the first is to add the tags, and the second is the incrementing tag number, so lets do it in two steps.
You are pretty much there with your regular expression search and replace. Do something like:
Search and Replace Variable with Regular Expression
Search for: (\d+(\.\d+)?)
Replace with: <xKMPLACEHOLDER/>$1<xKMPLACEHOLDER/>
The next problem is more challenging. A simple search and replace wont work. You could probably do it with a perl script, and you can also do it fairly efficiently using a For Each action, but its a bit tricky to get it both efficient and correct.
Presuming your text will not be humungous, you can loop while the KMPLACEHOLDER exists, split the text into three parts (before the first placeholder, the placeholder, and after the last placeholder), and then put it back together with the index and then increment the index and try again.