in reply to get first e.g. 5 words and replace the remaining string with ... with one regex

Does it have to be a regex? You can use split, if you don't mind the whitespace being mangled up. I guess you don't really care.
my @words = split / /, $string, 6; $words[-1] = '...' if @words==6; $string = join ' ', @words;
Hmm... that does add a space before the final ellipsis. A beauty spot, or a fatal flaw?
  • Comment on Re: get first e.g. 5 words and replace the remaining string with ... with one regex
  • Download Code