>perl -wMstrict -le "my $s = 'there is no FOO stuff i do not want BAR unwanted BAR stuff here'; ;; my $t = $s; $t =~ s{ FOO \K .*? (?= BAR) }{}xms; print qq{'$t'}; ;; $t = $s; $t =~ s{ FOO \K .* (?= BAR) }{}xms; print qq{'$t'}; " 'there is no FOOBAR unwanted BAR stuff here' 'there is no FOOBAR stuff here'