Code: Select all
<regex>^rot(\d+) (.*)</regex>
<script>
local KEY = matches[2]
local line = matches[3]
function Rotate(t)
return (string.gsub(t, "[%a]",
function (char)
local bUpper = (char < 'a')
local b = string.byte(string.upper(char)) - 65 -- 0 to 25
b = math.mod(b + KEY, 26)
if bUpper then
return string.char(b + 65)
else
return string.char(b + 97)
end
end
))
end
echo(Rotate(line).."\n")
</script>