in reply to How do I match lines of 40 characters long in a block of text?

Update: Answered the wrong question.

This is tougher than it looks.

Try m/(.{40}\n){4}/. It works for me...

perl> $" = '' perl> $s = ((qq(@{[0..8]}) x 4).$/)x4 perl> print $s 012345678012345678012345678012345678 012345678012345678012345678012345678 012345678012345678012345678012345678 012345678012345678012345678012345678 perl> print 'Matched'.$/ if ( $s =~ m/(.{40}\n){4}/ ) perl> $s = ((qq(@{[0..9]}) x 4).$/)x4 perl> print $s 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 perl> print 'Matched'.$/ if ( $s =~ m/(.{40}\n){4}/ ) Matched perl>

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: How do I match lines of 40 characters long in a block of text?
by kleinbiker7 (Sexton) on Sep 25, 2002 at 19:18 UTC
    Sorry, I rephrased my question wrong. I wanted it to match lines from 0 to 40 characters but no more than 40 characters. thanks.