RosettaCodeData/Task/Strip-control-codes-and-extended-characters-from-a-string/Lua/strip-control-codes-and-extended-characters-from-a-string.lua
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

25 lines
464 B
Lua

function Strip_Control_Codes( str )
local s = ""
for i in str:gmatch( "%C+" ) do
s = s .. i
end
return s
end
function Strip_Control_and_Extended_Codes( str )
local s = ""
for i = 1, str:len() do
if str:byte(i) >= 32 and str:byte(i) <= 126 then
s = s .. str:sub(i,i)
end
end
return s
end
q = ""
for i = 0, 255 do
q = q .. string.char(i)
end
print( Strip_Control_Codes(q) )
print( Strip_Control_and_Extended_Codes(q) )