I am looking to return a specific group in the previous row via regex.
Suppose I have the following information and the target is to extract the value 90 on the basis of the differentiation in the following line.
QTY+66:90:PCE
SCC+2
DTM+45:20200416:15
QTY+66:60:PCE
SCC+3
DTM+35:20210614:2
If I were to traget the value 90, I'd have to look for the SCC+2 tag and if I were to loom for the value 60, it would be the SCC+3 tag.
I got this far in an attempt to return the value 90 (?<=^QTY\+66:)(\d+)(.*\n.*SCC\+2.*) but it seems convoluted and I fail to extract only Group 1. Here is the link to regex101. I am using R for the actual application. Thanks for the help !