Module:String2/sandbox: Difference between revisions

Content deleted Content added
sync from main
upgrade posnq to ustring, named parameters, returned value
Line 110:
-- any double quotes " are stripped out.
p.posnq = function(frame)
local str = mw.text.trim(frame.args[1] or frame.args.source or "")
local match = mw.text.trim(frame.args[2] or frame.args.target or ""):gsub('"', '')
local plain = mw.text.trim(frame.args[3] or frame.args.plain or "")
if plain == "" then 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 = str:mw.ustring.find(str, match, 1, trueplain) or nomatch
return pos
end