Dinesh Ravi Dinesh Ravi - 1 month ago 10
Perl Question

Perl: How to pull out the desired string using the starting character but needs to include them as well?

I have this string

my $word = "Chase_^%798(987%55,.#*&^*&Chase_$&^**&(()%%hjjlhh";

Desired output is


The string
is the only clue using which I should separate them. Using split I lose the string
. Then I should concatenate them. I don't have the slightest idea of how to split it but also the string
should be present.`


Use lookahead:

my $str = 'Chase_^%798(987%55,.#*&^*&Chase_$&^**&(()%%hjjlhh';
my @list = split(/(?=Chase_)/, $str);
say Dumper\@list;


$VAR1 = [