Difference between revisions of "Module:SandboxUString"
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
function p.length() | function p.length() | ||
return ';byte\n:mw.ustring. | return ';byte\n:mw.ustring.len(\'a\') is ' .. mw.ustring.len("a") .. '\n' | ||
end | end | ||
Revision as of 06:50, 10 January 2022
Documentation for this module may be created at Module:SandboxUString/doc
local p = {}
ustring = require('ustring')
function p.byte()
return ';byte\n:mw.ustring.byte(\'a\') is ' .. mw.ustring.byte("a") .. '\n'
end
function p.length()
return ';byte\n:mw.ustring.len(\'a\') is ' .. mw.ustring.len("a") .. '\n'
end
function p.char()
return ';char\n:mw.ustring.char(224) is ' .. mw.ustring.char(224) .. '\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