Doesn't the ;?? mean match semi-colon 0 or 1 times and be non-greedy?
Yes, it does, but that's not what you want. You need the .+ to be non-greedy or else disallow semi-colons in your values:
To make the matching more robust, you'll want to do something like this:@{$pets} = $1 if $pet_list =~ /$some_variable\:(.*?)(;|\z)/; # or not allow ';' in values: @{$pets} = $1 if $pet_list =~ /$some_variable\:([^;]*)(;|\z)/;
@{$pets} = $1 if $pet_list =~ /(?:\A|;)\Q$some_variable\E\:([^;]*)(;|\ +z)/;
In reply to Re: Pattern Match n00b
by pc88mxer
in thread Pattern Match n00b
by USP45
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |