I have some text that repeats like this:
macro num 1
send (pta) (x1 var2 var3
save macro 'n'
macro num 2
send (pta) (x1 var3 var5 var7 var8 var10
save macro 'n'
macro num 3
send (pta) (x1 var5
The first and third lines are always the same (just counting up num 1, num 2, etc.), and the 2nd line always starts with 'send (pta) (x1'.
The thing I am hoping to do is put a closing ) around the end of the series of vars that come after 'send (pta) (x1 ...', and the tricky bit is they are all different ending vars (and there are varying numbers of vars) in the text. Ultimately I'd just want it to look like:
macro num 1
send (pta) (x1 var2 var3)
save macro 'n'
macro num 2
send (pta) (x1 var3 var5 var7 var8 var10)
save macro 'n'
macro num 3
send (pta) (x1 var5)
^send \(pta\) \([^)\r\n]+\K
\)
. matches newline
Explanation:
^ # beginning of line
send \(pta\) \( # literally
[^)\r\n]+ # 1 or more any character that is not ) or linebreak
\K # forget all we have seen until this position
Screenshot (before):
Screenshot (after):