in reply to Regex negation (or golf)
sub dequote { for (my $s = @_ ? $_[0] : $_) { s/^"//; s/"$//; return $_; } } { my $qstr = qr{"[^"]*"}; my $num = qr{\d+}; my $response = '"F059"3,"Invalid Recipient postal code format for s +pecified country."99,""'; my ($error, $code) = $response =~ /^$qstr$num,($qstr)($num),$qstr$/ or die("Unrecognized format\n"); $error = dequote $error; print("error: $error\n"); print("code: $code\n"); }
$qstr and dequote need to be adjusted to handle your (unmentioned) quoting mechanism.
|
|---|