Module:Sandbox/BrownHairedGirl/sandbox: Difference between revisions
imported>BrownHairedGirl (tweak) |
(No difference)
|
Latest revision as of 02:19, 28 September 2019
Documentation for this module may be created at Module:Sandbox/BrownHairedGirl/sandbox/doc
local p = {}
function patternSearchEncode(s)
return mw.ustring.gsub(s, "([%W])", "%%%1")
end
function p.main(frame)
local testProvince = "the Northwest Territories"
local pn = "Category:Ordovician Northwest Territories"
local retval =""
if (mw.ustring.match(testProvince, "^[tT]he ") ~= nil) then
retval = retval .. "\npn = '" .. pn .. "'"
retval = retval .. "\ntestProvince = '" .. testProvince .. "'"
local testProvinceStripped = mw.ustring.gsub(testProvince, "^[tT]he ", "", 1)
retval = retval .. "\ntestProvinceStripped = '" .. testProvinceStripped .. "'"
local testProvinceStrippedEncoded = patternSearchEncode(testProvinceStripped)
retval = retval .. "\ntest pattern without leading definite article, i.e. '" .. testProvinceStrippedEncoded .. "' ? "
if (mw.ustring.match(pn, "[^%w]" .. testProvinceStrippedEncoded .. "[^%w]") ~= nil)
or (mw.ustring.match(pn, "^" .. testProvinceStrippedEncoded .. "[^%w]") ~= nil)
or (mw.ustring.match(pn, "[^%w]" .. testProvinceStrippedEncoded .. "$") ~= nil)
or (mw.ustring.match(pn, "^" .. testProvinceStrippedEncoded .. "$") ~= nil) then
retval = retval .. "Yes"
else
retval = retval .. "No"
end
return retval
end
end
return p