StringTrim

StringTrim["string"]

trims whitespace from the beginning and end of "string".

StringTrim["string",patt]

trims substrings matching patt from the beginning and end.

Details and Options

  • Whitespace is taken to include any number of spaces, tabs, and newlines.
  • StringTrim[{s1,s2,},] gives the list of results for each of the si.

Examples

Basic Examples  (3)

Remove whitespace from ends of strings:

Remove multiple character types:

Remove initial space characters using a regular expression pattern:

Introduced in 2008
 (7.0)