Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
pattern matchingby perltux (Monk) |
on Oct 12, 2012 at 14:38 UTC ( [id://998704]=perlquestion: print w/replies, xml ) | Need Help?? |
perltux has asked for the wisdom of the Perl Monks concerning the following question: Hi, given the same identical input string, why does the following line return an array with 2 elements: my @parts=($sysex_dump =~ /\xF0C.[~z](..LM 0087[A-Z][A-Z].+?)(..LM 0087[A-Z][A-Z].+?)\xF7/gs);While this line only returns an array with the first of the above two elements: my @parts=($sysex_dump =~ /\xF0C.[~z](..LM 0087[A-Z][A-Z].+?)+\xF7/gs);I would have thought the '+' after the bracket should match more than once and assign all matches to the array? How do I get the second pattern match to assign all matches as multiple elements to the array?
Edited to add a self contained code example (the print and the for loop are just to check the array I get):
Back to
Seekers of Perl Wisdom
|
|