# string based my $str = 'Just another index+substr'; substr $str, 0, index $str, 'a'; # 'Just ' # regex based my $pattern = qr/o/; 'Just another zero-width positive look-behind' =~ s/\K$pattern.*//; # 'Just an'