Trim whitespace from end of string (LUA)
Basic implement to strip trailing whitespace from a string in lua.
Accepts a string, returns a string, simple
Similar To
- PHP: rtrim()
- Python: rstrip()
Details
- Language: LUA
Snippet
function rtrim(s)
return s:match'^(.*%S)%s*$'
end
Usage Example
local a = ' abcde '
print( a..'END' )
print(rtrim(a)..'END')