Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > String Manipulation > String Operations >

StringTrim

StringTrim["string"]
trims whitespace from the beginning and end of "string".
StringTrim["string", patt]
trims substrings matching patt from the beginning and end.
  • 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.
Remove whitespace from ends of string:
Remove multiple character types:
Remove initial space characters using a regular expression pattern:
Remove whitespace from ends of string:
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=
New in 7
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team