better regex for removing the comments
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Thu, 09 Apr 2015 22:06:56 +0200
changeset 100 e7f889e69790
parent 99 664b775b56bd
child 101 927613936dd2
better regex for removing the comments
lib/DNS/Vi.pm
--- a/lib/DNS/Vi.pm	Thu Apr 09 13:56:03 2015 +0200
+++ b/lib/DNS/Vi.pm	Thu Apr 09 22:06:56 2015 +0200
@@ -33,8 +33,11 @@
     foreach (@lines) {
 	# simplificated comment remover
 	# after the comment character no '"' is allowed!
-        s{^\s*;.*$}{};		  # strip comment lines
-	s{\s*;[^"]*$}{};	  # strip trailing comments
+#        s{^\s*;.*$}{};		  # strip comment lines
+#	s{\s*;[^"]*$}{};	  # strip trailing comments
+
+	# see https://regex101.com/r/cG6fK3/2
+ 	s{\s*(?:;)(?:(?:[^"]|"[^"]*")*$)}{};
         state $line;
         if (my $range = /(.*)\(\s*$/ .. /(.*)\)\s*/) {
             $line .= defined $1 ? $1 : $_;