Lets say I have a document that looks like the following
(001 [bla bla bla
bla bla bla])
(002 [bla
bla bla])
(003 [bla bla bla
bla bla bla])
(004 [bla
bla bla])
...
(199 [bla bla bla bla
bla])
So notice the open parenthesis with an three digits integer. Is there a text editor that is capable of adding a specific integer to all selected integers. In sublime text, I know how I could select all those integers by pressing ctrl+d after selecting the first open parenthesis a and then press the right arrow once and then press shift and right arrow three times to select all those integers. After selecting, is there a function in sublime text that could do a simple addition to those numbers. Say +10 so that the integers will be 011, 012, 013, ..., 219. If sublime text does not have this function, is there a text editor that has?
With the proviso that it's not strictly a text editor in the full sense and most certainly isn't SublimeText, my utility TextDistil will do this for you quite easily:
If your input is a bit trickier than this you may need to get fancier with the regular expression matches.
Following the comment below, here's what you need to do to match strings like 'C11-001'...
You should use a matching expression of 'C11-(?< out>\d+)' with an arithmetic substitution of '48+$1' (Note there is not meant to be a space between the < and out but I can't get the markup to work without it.)
This may seem a bit cryptic so I'll try to explain the various parts....
So to summarise the above, we're matching all strings that look like C11-001 etc, then feeding the digits after the hyphen to the arithmetic expression then substituting the results of that expression back into the 'out' group which happens to also be the digits after the hyphen.
As with the earlier example, you may need to add some extra steps if you want the resulting text to use exactly 3 digits after the hyphen. There are various ways to do this but I would suggest simply brute-forcing it by adding a couple of standard text substitutions like this....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With