RosettaCodeData/Task/Strip-whitespace-from-a-string-Top-and-tail/Lua/strip-whitespace-from-a-string-top-and-tail.lua
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

5 lines
322 B
Lua

str = " \t \r \n String with spaces \t \r \n "
print( string.format( "Leading whitespace removed: %s", str:match( "^%s*(.+)" ) ) )
print( string.format( "Trailing whitespace removed: %s", str:match( "(.-)%s*$" ) ) )
print( string.format( "Leading and trailing whitespace removed: %s", str:match( "^%s*(.-)%s*$" ) ) )