I am pretty new to regex's, so I was happy when my text wrapping expression worked - for the most part.
It messes up when I need to wrap lines with \n that don't end in a space.
If there is no space, it places last word on its own line before it should wrap. Otherwise it double \ns the line.
I can't figure out why.
can anyone help me out?
sub quickWrap {
my $data = @_[0];
my $wrapAt = 75;
if (scalar @_ > 1) {
$wrapAt = @_[1];
}
my $wrappedData ="";
while ($data =~ /[^|\n][^\n]{$wrapAt,}?[ |$|\n]/) {
$data =~ /([^|\n])([^\n]{1,$wrapAt})( )([\s|\S]*$)/;
$wrappedData .= "$`$1$2\n";
$data = "$4";
}
return "$wrappedData$data";
}thanks!
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
