Strip whitespace from a string/Top and tail

From Rosetta Code
Revision as of 01:25, 4 June 2011 by rosettacode>Markhobley (initial content)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The task is to demonstrate how to strip leading and trailing whitespace from a string. The solution should demonstrate the following three results:

  • String with leading whitespace removed
  • String with trailing whitespace removed
  • String with both leading and trailing whitespace removed

Template:QBasic

<lang qbasic> mystring$=ltrim(mystring$) ' remove leading whitespace

mystring$=rtrim(mystring$)           ' remove trailing whitespace
mystring$=ltrim(rtrim(mystring$))    ' remove both leading and trailing whitespace

</lang>