Greed helps here, of course. It always returns both halves of the string, though.sub cut { my ($str, $n) = @_; ($str =~ /^(?=.{$n})(.{0,@{[$n-1]}})\s(.*)$/s, $str, '')[0,1]; }
In reply to Re: Truncate string
by ariels
in thread Truncate string
by lshatzer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |