in reply to Re: Truncate a string (news lead?)
in thread Truncate a string (news lead?)

Ahh. Never use $1 unless you've checked the success of the match.
sub reduce_to_first_sentence { local $_ = shift; s/([.!?])\s.*/$1/s; $_; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Truncate a string (news lead?)
by mountd (Novice) on Sep 13, 2001 at 08:10 UTC
    except my example truncates @ any number of starting characters, not just the first sentence.