The first parameter splitdetermines what separates the elements you want to extract. bDon't share your elements that you want, as this is actually part of what you want.
You can specify the separation after busing
my @parts = split /(?<=b)/, $s;
You can also use
my @parts = $s =~ /[^b]*b/g;
Side note:
split /(?<=b)/
splits
a b c b b
at three points
a b|c b|b|
therefore, the result is four lines
Fortunately, it splitremoves trailing empty lines from its default result, so three needed lines are called instead.
source
share