RosettaCodeData/Task/Strip-whitespace-from-a-string-Top-and-tail/Lua/strip-whitespace-from-a-string-top-and-tail.lua
2023-07-01 13:44:08 -04: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*$" ) ) )