in reply to Re: Re: How do I match lines of UP TO 40 chars BUT NO MORE in a block of text?
in thread How do I match lines of UP TO 40 chars BUT NO MORE in a block of text?
Well, that's exactly what it should match. Your input matches your requirements. It has a block of text consisting of between 1 and 4 (1 in this case) lines of not more than 40 characters and an additional newline.
Your requirements are poorly specified.
Maybe, rather than see if your input matches such a block, you want to see if your input is such a block. If this is the case, your example input wouldn't work even if the second line had less than forty characters because your third line doesn't have a trailing newline.
If that is what you are trying to do, try this:
/ ^ # Anchor to beginning of string. (?: # Group each line. .{0,40}\n # 0 to 40 characters followed by a newline. ){0,4} # 0 to 4 lines. $ # Anchor to end of string. /x; # /x for comments.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: How do I match lines of UP TO 40 chars BUT NO MORE in a block of text?
by Anonymous Monk on Sep 26, 2002 at 01:57 UTC | |
by sauoq (Abbot) on Sep 26, 2002 at 02:11 UTC | |
by kleinbiker7 (Sexton) on Sep 26, 2002 at 15:06 UTC |