in reply to Re: Truncating after the last period
in thread Truncating after the last period
Not correctly it won't.
#!/usr/bin/perl use strict; use warnings; use open qw( :encoding(UTF-8) :std ); use Modern::Perl; my $string = ('X' x 400) . '.'; say length $string; # Prints 401 $string =~ s[^.{1,400}\.\K.*?$][]; say length $string; # Prints 401
It will also truncate a string in the middle of a character. And it won't truncate a string that doesn't have a FULL STOP (U+002E) in it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Truncating after the last period
by BrowserUk (Patriarch) on Aug 22, 2011 at 18:47 UTC | |
by Jim (Curate) on Aug 22, 2011 at 20:05 UTC | |
by BrowserUk (Patriarch) on Aug 22, 2011 at 20:11 UTC | |
by Jim (Curate) on Aug 22, 2011 at 20:24 UTC | |
by BrowserUk (Patriarch) on Aug 22, 2011 at 20:54 UTC | |
|