A question on whitespace is difficult to address as one cannot see the objects of interest. Your regex suggests that in a multiline string you want to replace lines consisting only of whitespaces with truly empty lines. Whitespaces in non-empty lines will be preserved. I am replacing the whitespace with 'x' to see where we got matches:
The result of this would be:use strict; use warnings; my $string = "next line is spaces next line is tabs and now some newlines end"; $string =~ s/^\s*$/x/mg; print "$string\n";
When you say you want to exclude newlines from the match, what is the desired effect you want to see? Preserve multiple empty lines?next line is spaces x next line is tabs x and now some newlines xx end
In reply to Re: regex doubt on excluding
by hdb
in thread regex doubt on excluding
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |