Skip to content

How to trim whitespace

Use $::str::trim to remove leading and trailing whitespace from a character vector:

      $::str::trim '  hello  '
hello

You can also import it for shorter syntax:

      #import $::str::trim
      trim '  hello  '
hello

The result is a character vector with the whitespace stripped from both ends.

See also: Character arrays, Standard library -- strings