Module:String2: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
fetch parent args
(upgrade posnq - Now supports named parameters: source, target, plain, nomatch; and UTC)
(fetch parent args)
Line 110:
-- any double quotes " are stripped out.
p.posnq = function(frame)
local strargs = mw.text.trim(frame.args[1] or frame.args.source or "")
local pargs = frame:getParent().args
local match = mw.text.trim(frame.args[2] or frame.args.target or ""):gsub('"', '')
for k, v in pairs(pargs) do
local plain = mw.text.trim(frame.args[3] or frame.args.plain or "")
args[k] = v
end
local str = mw.text.trim(args[1] or args.source or "")
local match = mw.text.trim(frame.args[2] or frame.args.target or ""):gsub('"', '')
if str == "" or match == "" then return nil end
local plain = mw.text.trim(frame.args[3] or frame.args.plain or "")
if plain == "false" then plain = false else plain = true end
local nomatch = mw.text.trim(frame.args[4] or frame.args.nomatch or "")
if str == "" or match == "" then return nil end
-- just take the start position
local pos = mw.ustring.find(str, match, 1, plain) or nomatch
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu