[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] string evenness




Jeff Pinyan wrote:
> 
> On Dec 1, Jeff Pinyan said:
> 
> >  $half = int(length($str)/2);
> >  $str =~ s{( ?)([^ ]*)(?<=^.{$half})([^ ]*)( ?)}
> >           { length($2) < length($3) ? "\n$2$3$4" : "$1$2$3\n" }e;
> 
> Generalized (I wish I could get it with one regex, but alas):

Is that all you want?  ;-)

    $str =~ s/ (??{"(?!.* .{$-[0]})"})/\n/s;

-- 
Rick Delaney
rick.delaney@home.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe