Is it possible with sed to replace a line with capture groups from the regex?
I have this regex, please note that this is fixed, I cannot change it.
si
Perl to the rescue!
perl -ne 'if (/(.*)simple sample (.*) with (.*)/) {
print "$1$2\n";
} else { print }'
Like this?
echo "This is just a simple sample line with some text" | \
sed 's/simple sample \(.*\)/\n\1/;s/.*\n//'
The idea is simple: replace the whole regexp match with the captured group preceded by a newline. Then replace everything up to and including the first newline with nothing. Of course, you could use a marker other than the newline.