Skip to main content
trimspace(str) removes all leading and trailing whitespace characters from str, including spaces, tabs, and newlines.

Signature

Example

Read a project name from a configuration file and strip any accidental whitespace before using it in commands:
If .project contains myapp\n, computed.project becomes myapp.

Notes

  • trimspace removes whitespace from both ends. It does not affect whitespace in the middle of the string.
  • To remove only trailing newlines, use chomp.
  • To remove a specific set of characters, use trim.