Have you considered splitting the string on "), XX("? Something like:
@chunks = split /\), ([A-Z][A-Z])\(/, $input;
That'll give you all the values interspersed with the prefixes (with the first and last elements being wacky because you matched on the stuff that goes between each value).
In fact, you could make the split pattern a bit more complex, to separate out the first "AA(" and the last ")":
@chunks = split /(?: (?:^|\),\s) ([A-Z][A-Z])\( | \)$)/x, $input; shift @chunks; # remove extra blank element at front
Then you can use part from List::MoreUtils to partition the list into prefixes and values, or you could just assign it to a hash and use it directly:
use List::MoreUtils qw(part); my @chunks = ...; # as above shift @chunks; # as above my $ix = 0; my ($prefixes,$texts) = part {++$ix % 2} @chunks; # or my %text = @chunks; say "Text value AF is $text{AF}";
In reply to Re: Character Text Delimiters
by Sue D. Nymme
in thread Character Text Delimiters
by Ninthwave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |