Anonymous user
Module:ISO 3166: Difference between revisions
no edit summary
(Apparently 3166-2 codes can have mixed letters and digits) |
No edit summary |
||
Line 14:
local function strip(text)
text = string.upper(text) --Case insensitivity
text = string.gsub(text,"[%s%-%,%.%(%)%/%\']","") --Remove spacing and punctuation
text = string.gsub(text,"^THE ","") --Remove definite article
--text = string.gsub(text,"[\768-\879]","") --Unicode deaccenting doesn't work
return text
Line 22 ⟶ 23:
local function findname(code,cdata,qry)
local sqry = strip(qry)
if cdata["name"] and sqry==strip(cdata["name"])
then
▲ if cdata["isoname"] and sqry==strip(cdata["isoname"]) then
return true
end
for _,tname in ipairs(cdata["altnames"] or {}) do
if sqry==strip(tname) then
▲ if sqry==code or sqry==cdata["alpha3"] or sqry==cdata["numeric"] then
return true
end
|