Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

shell trim

STR="${STR//(^[ ]+|[ ]+$)/}"

# ${STR//--regex--/--replacement--} = replace all
# ${STR/--regex--/--replacement--} = replace one
# ^[ ]+ = empty character([ ])s(+) at the start(^) of the string
# [ ]+$ = empty character([ ])s(+) at the end($) of the string
# (A|B) = A or B
 
PREVIOUS NEXT
Tagged: #shell #trim
ADD COMMENT
Topic
Name
2+7 =