3 ms·
As perlfaq4[1] shows: > You can do that with a pair of substitutions: > s/^\s+//; > s/\s+$//; It then notes, in an understated ma
by nanis 10y ago
As perlfaq4[1] shows:
> You can do that with a pair of substitutions:
> s/^\s+//;
> s/\s+$//;
It then notes, in an understated manner:
> You can also write that as a single substitution,
> although it turns out the combined statement is
> slower than the separate ones. That might not
> matter to you, though:
> s/^\s+|\s+$//g;
[1]: http://perldoc.perl.org/perlfaq4.html#How-do-I-strip-blank-space-from-the-beginning%2fend-of-a-string%3f http://perldoc.perl.org/perlfaq4.html#How-do-I-strip-blank-s...
- cygx 10y agoIn light of the given issue, it might be a good idea to update the example code to use \s++ instead...