On Mar 6, M z said:

>I've written a little program to analyze lines that
>are longer than 70 characters, and if so, break at
>position 70 (if it is whitespace), if not whitespace
>(i.e. is in the middle of a word) it steps back to the
>first whitespace and breaks there.

  s/(.{1,70})\s/$1\n/g;

That says "match between 1 and 70 characters (as many possible) and then a
piece of whitespace" and replace it with the same text, except convert the
whitespace into a newline.  And the /g modifier says "do it for all
occurrences".

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to