StringTrim

StringTrim["string"]
trims whitespace from the beginning and end of .

StringTrim["string",patt]
trims substrings matching patt from the beginning and end.

DetailsDetails

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

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Remove whitespace from ends of strings:

In[1]:=
Click for copyable input
Out[1]//FullForm=

Remove multiple character types:

In[1]:=
Click for copyable input
Out[1]//FullForm=

Remove initial space characters using a regular expression pattern:

In[1]:=
Click for copyable input
Out[1]//FullForm=
Introduced in 2008
(7.0)