WHolcomb has asked for the wisdom of the Perl Monks concerning the following question:
And that has caught every test case I have made up, like:$m = "\\"; # Meta $c = "\#"; # Comment print "Begin: $_\n"; split /\Q$c\E/; $string = $_ = $_[0]; # Because split puts the first non-blank line +in $_ for($i = 1; $i <= $#_; $i++) { $_ = $_[$i - 1]; (/((^|[^\Q$m\E])((\Q$m\E){2})*$)/) ? (last) : ($string .= "$c" . $_[ +$i]); } print " End: $string\n";
this is a line with a \# pound # and a comment this is a \# line with three \#'\#'s # and a comment this is a line \\\\ with shashes \\\\# and a comment this is a line \\\\ with shashes \\\# and a pound # and a comment #this line is only comment \#this line begins with a pound \\# This line begins with a slash \# This line \# \\# has a pound at the beginningCan anyone come up with a regex to do the same job?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: quoting characters
by ahunter (Monk) on Apr 14, 2000 at 19:28 UTC | |
by Anonymous Monk on Apr 14, 2000 at 23:37 UTC | |
|
Re: quoting characters
by turnstep (Parson) on Apr 14, 2000 at 19:56 UTC | |
|
Re: quoting characters
by turnstep (Parson) on Apr 14, 2000 at 19:56 UTC |