in reply to Re^2: Regex Inline Match operator ?m
in thread Regex Inline Match operator ?m

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

Replies are listed 'Best First'.
Re^4: Regex Inline Match operator ?m
by josh803316 (Beadle) on May 06, 2010 at 01:58 UTC
    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.

      Have you tried the regex I suggested?  Works for me:

      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', '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' ]; foreach my $test (@$tests) { if($test =~ qr/^((^|\n)Nov 29 [^\n]*)+$/s) { print "$test\n REGEX MATCHED\n"; } else { print "$test\n FAILED!\n"; } } __END__ 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 REGEX MATCHED 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 FAILED!

      Or modify ikegami's regex like this:

      qr/^(?:Nov 29 [^\n]*(\n|$))*\z/s ^^^^^^ newline or end-of-line
        Thanks a ton, that works perfectly!