I have three lines of tab-separated values:
The first two have 'SELL' or 'BUY' as first value but the third one has not, hence a Tab mark where I wrote ______
:
I would like to capture the following using Regex:
My expression ^(BUY|SELL).+?\r\n\t
does not work as it gets me this:
I do know why outputs this - adding an lazy-maker '?' obviously won't help. I don't get lookarounds to work either, if they are the right means at all. I need something like 'Match \r\n\t only or \r\n(?:^\t) at the end of each line'.
The final goal is to make the three lines look at this at the end, so I will need to replace the match with capturing groups:
Can anyone point me to the right direction?
^(BUY|SELL).+\R\K\t
$1\t
. matches newline
Explanation:
^ # beginning of line
(BUY|SELL) # group 1, BUY or SELL
.+ # 1 or more any character but newline
\R # any kind of linebreak
\K # forget all we have seen until this position
\t # a tabulation
Replacement:
$1 # content of group 1
\t # a tabulation
Screenshot (before):
Screenshot (after):