My reply at Re: How do I match lines of 40 characters long in a block of text? does what you want I think. Note that you don't really want to match 0 lines unless you want everything to match. Also, when you are constructing a regex, it is best to be able to state exactly what you want. I think you really want "1 to 4 lines each consisting of 0 to 40 characters followed by a newline." I've included the code from original reply below for your convenience.
/ ( # Assuming you want capture these lines. (?: # Group each line. ^ # Beginning of the line. .{0,40}\n # 0 to 40 characters followed by a newline. ){1,4} # 1 to 4 lines. (0 will permit an empty match.) ) # Done capturing. /mx; # /m so that ^ anchor works, /x for comments.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: How do I match lines of UP TO 40 chars BUT NO MORE in a block of text?
by sauoq
in thread How do I match lines of UP TO 40 chars BUT NO MORE in a block of text?
by kleinbiker7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |