github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/trim.mdx (about)

     1  ---
     2  page_title: trim - Functions - Configuration Language
     3  description: >-
     4    The trim function removes the specified set of characters from the start and
     5    end of
     6  
     7    a given string.
     8  ---
     9  
    10  # `trim` Function
    11  
    12  `trim` removes the specified set of characters from the start and end of the given
    13  string.
    14  
    15  ```hcl
    16  trim(string, str_character_set)
    17  ```
    18  
    19  Every occurrence of a character in the second argument is removed from the start
    20  and end of the string specified in the first argument.
    21  
    22  ## Examples
    23  
    24  ```
    25  > trim("?!hello?!", "!?")
    26  "hello"
    27  
    28  > trim("foobar", "far")
    29  "oob"
    30  
    31  > trim("   hello! world.!  ", "! ")
    32  "hello! world."
    33  ```
    34  
    35  ## Related Functions
    36  
    37  * [`trimprefix`](/language/functions/trimprefix) removes a word from the start of a string.
    38  * [`trimsuffix`](/language/functions/trimsuffix) removes a word from the end of a string.
    39  * [`trimspace`](/language/functions/trimspace) removes all types of whitespace from
    40    both the start and the end of a string.