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):
my @parts=("\xF0C.z..LM 0087AAaaa..LM 0087BBbbb\xF7"=~ /\xF0C.[~z](. +.LM 0087[A-Z][A-Z].+?)+\xF7/s); print STDERR @parts." parts\n"; for($a = 0; $a < @parts; $a++) { print STDERR ($a+1).": ".length($parts[$a])." length\n"; }
In reply to pattern matching by perltux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |