Module:Sandbox

From PKC
Revision as of 06:22, 10 January 2022 by Benkoo (talk | contribs) (Created page with "local p = {} function p.byte() return ';byte\n:string.byte(\'A\') is ' .. string.byte('A') .. '\n' end function p.char() return ';char\n:string.char(65) is ' .. st...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Sandbox/doc

local p = {}
 
function p.byte()
    return ';byte\n:string.byte(\'A\') is ' .. string.byte('A') .. '\n'
end
 
function p.char()
    return ';char\n:string.char(65) is ' .. string.char(65) .. '\n'
end
 
function p.find()
    return ';find\n:string.find(\'that\', \'at\') is ' .. string.find('that', 'at') .. '\n'
end
 
function p.format()
    return ';format\n:string.format(\'%.2f\', 0) is ' .. string.format('%.2f', 0) .. '\n'
end
 
function p.gmatch()
	local result = ';gmatch\n:'
	for word in string.gmatch('This is a test', '%w+') do
		result = result .. word .. '-'
	end
    return result .. '\n'
end
 
function p.gsub()
    return ';gsub\n:string.gsub(\'This is a test\', \'%s\', \'-\') is ' .. string.gsub('This is a test', '%s', '-') .. '\n'
end
 
function p.len()
    return ';len\n:string.len(\'len\') is ' .. string.len('len') .. '\n'
end
 
function p.lower()
    return ';lower\n:string.lower(\'LOWER\') is ' .. string.lower('LOWER') .. '\n'
end
 
function p.match()
    return ';match\n:string.match(\'This is a test!\', \'.\', -1) is ' .. string.match('This is a test!', '.', -1) .. '\n'
end
 
function p.rep()
    return ';rep\n:string.rep(\'*\', 5) is ' .. string.rep('*', 5) .. '\n'
end
 
function p.reverse()
    return ';reverse\n:string.reverse(\'reverse\') is ' .. string.reverse('reverse') .. '\n'
end
 
function p.sub()
    return ';sub\n:string.sub(\'that\', 2, 3) is ' .. string.sub('that', 2, 3) .. '\n'
end
 
function p.upper()
    return ';upper\n:string.upper(\'upper\') is ' .. string.upper('upper') .. '\n'
end
 
return p