igoryonya has asked for the wisdom of the Perl Monks concerning the following question:
I thought, I would get this result:my $equation = '979x + 87y - 8723z = 274320'; my @parts = ($equation =~ /^(?:(.*?)([xyz]))+/i);
but, instead, I get (only the last match from the string, not all of them):@parts = ('979', 'x', ' + 87', 'y', ' - 8723', 'z');
What am I missing here?@parts = (' - 8723', 'z');
So, instead of getting (which is desirable):my $equation = '979x + 87y - 8723z = 274320'; my @parts = ($equation =~ /^(?:(.*?)([xyz]))+(.*)=(.*)$/i);
I am getting:@parts = ('979', 'x', ' + 87', 'y', ' - 8723', 'z', ' ', ' 274320');
@parts = (' - 8723', 'z', ' ', ' 274320');
|
|---|