Module:Sandbox/DutyS12345

-- local p   = {}

local lib      = require('Module:Feature') -- local json     = require('Module:JSON') -- local userError = require('Dev:User error') -- local FN       = require('Module:Filename')

--[=[   does not strip URI links FSM States: s=0 Seen s=1 Seen [ s=2 Seen [\[ s=3 Seen [\[ + s=4 Seen [\[ *: s=5 Seen [\[ *: + s=6 Seen [\[ *: *.*] s=7 Seen [\[ *:?.* s=8 Seen [\[ *:?.*] s=9 Seen [\[ *:?.*| s=10 Seen [\[ *:?.*|.* s=11 Seen [\[ *:?.*|.*] s=11 Seen [\[ *:?.*|] s=. Seen [ + s=. Seen [ *.* s=. Seen [ *.* s=. Seen [ *.* * s=. Seen [ *.* *.* ]=] function p.striplinks(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end local instring = args[1] local ret = '' local fstart, fend, bstart, bend, fcolon, fpipe local s = 0 for i = 1, #a do --       local nextchar = string.gmatch(args[1],'.') local nextchar = mw.ustring.sub(instring, i, i)       if s == 0 then if nextchar == '[' then s = 1 fstart = i           else s = 0 ret = ret .. nextchar end elseif s == 1 then --Seen [ if nextchar == '[' then s = 2 fend = i           end elseif s == 2 then --Seen [[           if nextchar == ' ' then                s = 3                fend = i-1            elseif nextchar == ':' then                s = 13            else                s = 7            end        elseif s == 3 then --Seen [[ +            if nextchar == ' ' then                s = 3                fend = i-1            elseif nextchar == ':' then                s = 4                fcolon = i            end        elseif s == 4 then --Seen [\[ +:            if nextchar == ']' then                s = 8            elseif nextchar == ' ' then                s = 5            else                s = 7            end        elseif s == 5 then --Seen [\[ *: +            if false then            else                s = 6            end        elseif s == 6 then --Seen [\[ *: .*]        elseif s == 7 then --Seen [\[ *:?.*            if nextchar == '|' then                s = 9                fpipe = i            else                s = 7            end        elseif s == 8 then --Seen [\[ *:?.*]        elseif s == 9 then --Seen [\[ *:?.*|            if nextchar == ']' then                s = 12                bstart = i            else                s = 9            end        elseif s == 10 then --Seen [\[ *:?.*|.*            if nextchar == ']' then                s = 11                bstart = i            else                s = 10            end        elseif s == 11 then --Seen [\[ *:?.*|.*]            if nextchar == ']' then                s = 0                ret = ret .. mw.ustring.sub(instring, pipe + 1, bstart - 1)            else            end        elseif s == 12 then --Seen [\[ *:?.*|]            if nextchar == ']' then                s = 0                ret = ret .. mw.ustring.sub(instring, fend + 1, pipe - 1)            else                s = 10            end        elseif s == 13 then --Seen [[:            if nextchar == ']' then            elseif nextchar == ' ' then                s = 5            end        elseif s == 14 then        elseif s == 15 then        elseif s == 16 then        else            return instring        end    end    if s ~= 0 then return 'error, ended in state ' .. s .. ': ' .. ret end    return ret end function p.test(frame)    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end    return args[1] .. #args[1] end

return p -- --