The following code seems to work for me:
my $s = "one of his best tracks. It's good. His other notew"; $s =~ s/([.?!]).*$/$1/; print $s, "\n"; __OUTPUT__ one of his best tracks.
This handles sentences ending with a period, question mark, or exclamation point. It does not handle quotations properly (like, ...around here."), but I'm sure you could extend it to handle those cases.
Update Damn, too fast at the keyboard. If I looked more closely at the OUTPUT I would have noticed that my code doesn't work.
Update II Fixed the regex. It should read:
my $s = "one of his best tracks. It's good. His other notew"; $s =~ s/([.?!])[^.?!]*$/$1/; print $s, "\n"; __OUTPUT__ one of his best tracks. It's good.
Sorry for the earlier mistake.
In reply to Re: Truncating Last Sentence
by Belgarion
in thread Truncating Last Sentence
by FatDog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |