in reply to regex is not working as I intended
use strict; use warnings; use Test::More tests=>3; use Regexp::Common 'RE_ALL'; my @cases = ( [q(Now is the time), 'unquoted'], [q('Now is the time'), 'single quoted'], [q("Now is the time"), 'double quoted'], ); foreach my $case (@cases) { $_ = $case->[0]; my $string = /\"(.*)\"/ ? $1 : /\'(.*)\'/ ? $1 : /[^"'].*[^'"]/ ? $& : 'No Match' ; ok($string eq 'Now is the time', "$case->[1] found $string" ); } C:\Users\Bill\forums\monks>perl fireblood.pl 1..3 ok 1 - unquoted found Now is the time ok 2 - single quoted found Now is the time ok 3 - double quoted found Now is the time
|
---|