Hi ikegami,
Thanks for your example. I'm still trying to figure it all out. I'm running it as below, and it doesn't seem to quite do what I want. I only want the escape character to be treated specially if it's in !+; - i.e. a!!b should be a!!b, whereas a!!!;b should be a!;b.
Also, I seem to be getting an empty field at the end. One or more semicolons at the end seem to be parsed properly, though.
One test string returns a blank result. ?
sub dequote {
my $x = $_[0];
$x =~ s/!(.)/$1/sg;
return $x;
}
while(<>) {
chomp;
my @fields = map dequote($_), /\G((?:[^!;]+|!.)*)(?:;|\z)/sg;
print "$_ => " . join( '|', @fields ) . "\n";
# print "$_ => @fields\n";
}
Sample results:
aval!!!!;bval => aval!!|bval|
aval!!!!!;bval => aval!!;bval|
a!!val!!!!!;bval! =>
!a!!!val!!!!!;bval!! => a!val!!;bval!|
a!val!;bva!l; => aval;bval|
a!!val!!;;bv!!al;; => a!val!||bv!al||
|