in reply to Regex Inline Match operator ?m

my $re = qr/^(?:Nov 29 [^\n]*\n)*\z/s; print(/$re/ ? "pass\n" : "fail\n") for <<'__EOI__', <<'__EOI__'; Nov 29 16:01:27 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:28 Nov 30 16:01:22 __EOI__ Nov 29 16:01:27 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:28 __EOI__
fail pass

Replies are listed 'Best First'.
Re^2: Regex Inline Match operator ?m
by josh803316 (Beadle) on May 06, 2010 at 01:14 UTC
    This fails in my test, I must have changed something....
    my $tests = [ 'Nov 29 16:01:27 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:22' ]; # Put the regex you want to test in here. foreach my $test (@$tests) { if($test =~ qr/^(?:Nov 29 [^\n]*\n)*\z/s) { print "$test\n REGEX MATCHED\n"; } else { print "$test\n FAILED!\n"; } } Nov 29 16:01:27 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:28 Nov 29 16:01:22 FAILED!

      ikegami's regex requires a trailing newline, which you don't have in your test case.

        Thanks for all the responses.....I'm close but still stuck on how I would change it to match when the last line didn't have a newline at the end.