in reply to repeated regex capture
ormy $str = 'A2ABA45'; my @parts = $str =~ /A[^A]*/g;
To explain why you have undef's in your first attemptmy @parts = split /(?=A)/, $str;
You're treating your wanted text as delimiters that are captured in the split. Just look at this example.use Data::Dumper; my @parts = split /(A.+?)(?=A|$)/, "A2ABA45"; print Dumper(\@parts);
my @parts = split /(-)/, "-1-2-"; print Dumper(\@parts);
|
|---|