Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 98c23539

Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt

  • ID 98c23539610c6d083265454858ef25e563f74b21
  • Vorgänger 97eb7f68
  • Nachfolger abc7a54c

trim-Funktion zum Entfernen führender und anhängender Whitespaces

Unterschiede anzeigen:

SL/Util.pm
6 6

  
7 7
use Carp;
8 8

  
9
our @EXPORT_OK = qw(_hashify camelify snakify);
9
our @EXPORT_OK = qw(_hashify camelify snakify trim);
10 10

  
11 11
sub _hashify {
12 12
  my $keep = shift;
......
31 31
  lc $str;
32 32
}
33 33

  
34
sub trim {
35
  my $value = shift;
36
  $value    =~ s{^ \p{WSpace}+ | \p{WSpace}+ $}{}xg if defined($value);
37
  return $value;
38
}
39

  
34 40
1;
35 41
__END__
36 42

  
......
90 96

  
91 97
L</camilify> does the reverse.
92 98

  
99
=item C<trim $string>
100

  
101
Removes all leading and trailing whitespaces from C<$string> and
102
returns it. Whitespaces within the string won't be changed.
103

  
104
This function considers everything matching the Unicode character
105
property "Whitespace" (C<WSpace>) to be a whitespace.
106

  
93 107
=back
94 108

  
95 109
=head1 BUGS

Auch abrufbar als: Unified diff