Module:String2: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(don't trim the separator) |
(upgrade posnq - Now supports named parameters: source, target, plain, nomatch; and UTC) |
||
Line 110: | Line 110: | ||
-- any double quotes " are stripped out. |
-- any double quotes " are stripped out. |
||
p.posnq = function(frame) |
p.posnq = function(frame) |
||
local str = mw.text.trim(frame.args[1] or "") |
local str = mw.text.trim(frame.args[1] or frame.args.source or "") |
||
local match = mw.text.trim(frame.args[2] or ""):gsub('"', '') |
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 == "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 |
if str == "" or match == "" then return nil end |
||
-- just take the start position |
-- just take the start position |
||
local pos = |
local pos = mw.ustring.find(str, match, 1, plain) or nomatch |
||
return pos |
return pos |
||
end |
end |