Table of Contents
string_trim
Table of Contents
Prototype: string_trim(string)
Return type: string
Description: Trim whitespace from beginning and end of string
.
Arguments:
string
:string
- Input string - in the range:.*
Example:
bundle agent example_trim
{
vars:
"my_string_one" string => string_trim( " Trim spaces please ");
"my_string_two" string => string_trim( "
Trim newlines also please
");
reports:
"my_string_one: '$(my_string_one)'";
"my_string_two: '$(my_string_two)'";
}
bundle agent __main__
{
methods: "example_trim";
}
R: my_string_one: 'Trim spaces please'
R: my_string_two: 'Trim newlines also please'
This policy can be found in
/var/cfengine/share/doc/examples/string_trim.cf
and downloaded directly from
github.
History: Introduced in CFEngine 3.16
See also: string_head()
, string_tail()
string_length()
, string_reverse()
.