[thelist] Perl - regular expressions

ss momd mhmd_24h at hotmail.com
Sat Dec 8 21:23:31 CST 2001



>From: Mal Wins <malwinsc at yahoo.com>
>Reply-To: thelist at lists.evolt.org
>To: thelist at lists.evolt.org
>Subject: Re: [thelist] Perl - regular expressions
>Date: Sat, 8 Dec 2001 19:03:20 -0800 (PST)
>
>
>--- Dean Mah <dmah at shaw.ca> wrote:
> > This only works for the first couple of segments.
> > Using the loop
> > method it doesn't matter how long the text is, it
> > will iterate through
> > the entire thing and break it into <= 99 character
> > segments.
> >
>I could be wrong but I got the impression it was for a
>teaser line , about the only use I saw for it
>immediately. 99 char pages, just don't see the point.
>But no mention of skipping HTML tags so maybe he wants
>it in chunks. Either way thats a sweet regex.
>
> > You're right.  So instead try something like:
> >
> >    while ($var =~ /(.{1,99})[\s\n]/gs) {
> >        print "$1\n\n";
> >    }
> >
> > That will treat your string as a single line so the
> > '.' will match
> > newlines as well.
> >
> > Dean
>That does do the trick. I tried it (mistakenly) with
>the /m and overlooked the /s. Next time I'll look it
>up.
>
>
>__________________________________________________
>Do You Yahoo!?
>Send your FREE holiday greetings online!
>http://greetings.yahoo.com
>
>---------------------------------------
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the thelist mailing list