in reply to get first e.g. 5 words and replace the remaining string with ... with one regex
Hmm... that does add a space before the final ellipsis. A beauty spot, or a fatal flaw?my @words = split / /, $string, 6; $words[-1] = '...' if @words==6; $string = join ' ', @words;
|
|---|