X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/bc3a01aef9a58d5e22137dbcc38fec7abebfdb22..a2bab345aedcfbb03bdf0e0aa1f28a5c57a5d02b:/SL/Util.pm diff --git a/SL/Util.pm b/SL/Util.pm index 2fdd9c1f6..9022d939b 100644 --- a/SL/Util.pm +++ b/SL/Util.pm @@ -6,7 +6,7 @@ use parent qw(Exporter); use Carp; -our @EXPORT_OK = qw(_hashify camelify snakify); +our @EXPORT_OK = qw(_hashify camelify snakify trim); sub _hashify { my $keep = shift; @@ -31,6 +31,12 @@ sub snakify { lc $str; } +sub trim { + my $value = shift; + $value =~ s{^ \p{WSpace}+ | \p{WSpace}+ $}{}xg if defined($value); + return $value; +} + 1; __END__ @@ -90,6 +96,14 @@ return C. L does the reverse. +=item C + +Removes all leading and trailing whitespaces from C<$string> and +returns it. Whitespaces within the string won't be changed. + +This function considers everything matching the Unicode character +property "Whitespace" (C) to be a whitespace. + =back =head1 BUGS