Jump to content

Module:Sandbox/Zyxw/test

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Zyxw (talk | contribs) at 10:02, 1 January 2017 (test). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local p = {}

function p.main(frame)

    local inputString = frame.args[1]

    if inputString == '' then
        return inputString
    end
        
    if not inputString:match('^%d{4} *%a{3,9} *%d{1,2}$') then
        return inputString
    end

    local value1, value2, value3 = string.match(inputString, "^(%d{4}) *(%a{3,9}) *(%d{1,2})$")
    return value3 .. ' ' .. value2 .. ' ' .. value1

end

return p