3.149.213.209 |    

Navigation

Google Advertisement

Die Funktion trim() ist der gleichnamigen PHP Funktion nach empfunden. Sie entfernt Whitespaces am Anfang und Ende eines Strings. Die Funktion kann den String als Parameter $1 aber auch durch STDIN entgegen nehmen.

trim
  1. # *******************************************************
  2. # This function is like the php function trim,
  3. # witch removes all spaces in front & back of a string.
  4. #
  5. # @param <STDIN>|$1 - The string as param or pipe stream
  6. # @return string
  7. #
  8. function trim () {
  9.  
  10. if [ -n "$1" ]; then
  11.     echo $1 | perl -p -e 's/^\s+|\s+$//g'
  12. else
  13.     cat - | perl -p -e 's/^\s+|\s+$//g'
  14. fi
  15.  
  16. }
Parsed in 0.002 seconds at 232.87 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 4 users online.

Tags Cloud

Latest snippets
str2seconds
(Bash::Function)
is_integer
(Bash::Function)
file_rotate
(Bash::Function)
confirm
(Bash::Function)
is_workingtime
(Bash::Function)
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)