[thelist] Perl - regular expressions

Dean Mah dmah at shaw.ca
Sat Dec 8 12:28:12 CST 2001


Try something like:

while ($var =~ /(.{1,99})[\s\n]/g) {
   print "$1\n\n";
}

I haven't tested it extensively but it should get you closer.

Dean


Roee Rubin writes:

> I would like to split the paragraph into two parts (which ultimately will be
> displayed in two pages). The trick, however is that I do not wish to split
> in the middle of the word. I have a budget of, lets say 99 characters which
> will split the word "its" right in the middle. I would like page to
> essentially display up to character 99 minus first (or last) white space (I
> think that makes sense).




More information about the thelist mailing list