in reply to Re: 30 Spaces- 1 question
in thread 30 Spaces- 1 question
I appreciate your liking my REx, but be careful; that \s* is a `*' for a reason. Try yours out:
[~] $ perl -wnle'/^((?:\S+\s+){1,30})/;print $1' one two three four five six seven one two three four five six
versus mine:
[~] $ perl -wnle'/^((?:\S+\s*){1,30})/;print $1' one two three four five six seven one two three four five six seven
Also, your split solution has a minor problem:
[~] $ perl -wnle'@w=split/\s+/,$_,31;pop@w;print join " ",@w' one two three four five one two three four
(Granted, the problem specs weren't that great, but it seems reasonable to assume that if we have a line with less than 30 words, we don't want to throw away the last.)
-dlc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: 30 Spaces- 1 question
by extremely (Priest) on Oct 09, 2000 at 10:07 UTC | |
by dchetlin (Friar) on Oct 09, 2000 at 11:07 UTC |