in reply to Re: Multiline match for empty string
in thread Multiline match for empty string
#!/usr/bin/perl use strict; use warnings; my @tests = ("\% only 1 profile is allowed\n\n", # Should fail "\n\n", # Should pass "", # Should pass ); my $regex = "(?!.*\\S)"; for (@tests) { print $_ =~ qr{$regex}ms ? "$_\n REGEX MATCHED\n" : "$_\n FAILED!\ +n"; }
Like with the bad OP proposal, your regex passes for all cases.
Update: Fixed mistake in posted test, though it does not change the result. See below for corrected regular expression.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Multiline match for empty string
by ikegami (Patriarch) on Aug 05, 2010 at 23:00 UTC |