Ok, I've got another:

I have a really long string (2000ish chars), I want to break it into
multiple strings of 80 chars or less.
The Catch is, I need to break it on a space (' '), hence the "or less".  It
seems, I should be able to
use a regex on this.

Currently I do it like:

$lineLength = 80;
$line = #some really long string#;

# essentially while the line is longer than 80 chars
# find the right most ' ' or ',' up to a maximum of 80 chars
# from the beginning
# break off that piece of the string and start over
while (length($line) > $lineLength) {
   my $space = rindex(substr($line,0,$lineLength),' ') ||
      rindex(substr($line,0,$lineLength),',');
      print substr($line,0,$space)."\n";
      substr($line,0,$space) = '';
}
print "$line\;\n";

Seems like I should be able to do it (somehow) with a regex sorta like

foreach ($line =~ m/(" ")/g) { # but somehow specify a length
    print $_;
}

Any ideas?
Thanks
Jay


----- Original Message -----
From: "Ted Deppner" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 14, 2001 3:36 AM
Subject: Re: [vox-tech] Looking for 2 cool regexs


> On Thu, Sep 13, 2001 at 11:05:48AM -0500, Jay Strauss wrote:
> > find any CREATEwhitespaceTABLEanycharsnot; and replace them with ''.
the
> > whole lot of it has to start at a word boundary.
>
> right on...
>
> > I've never done this before, I didn't know you could produce a  list
from a
> > match command.
>
> It's nifty...  the concept is an expansion on
>   ($a,$b,$c) = $var =~ m/(re1)(re2)(re3)/
>   (where $1,$2,$3 are returned in a list context)
>
> --
> Ted Deppner
> http://www.psyber.com/~ted/


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to