I have a perl oneliner:
echo -e 'sla\ndfjAAAAk\nsaljdfla\nsjdfBBBBsadf\njasdf' | perl -E 'my $_ = do { local $/; <> }; say join qq!\n!, m!\QAAAA\E\K(.*?)(?=\QBBBB\E)!gs'
k
saljdfla
sjdf
it works, but I need this output:
dfjAAAAk
saljdfla
sjdfBBBBsadf
so I need the lines that contains "AAAA" and "BBBB" too - not just "from" and "to" them. How can I do this?