Module:ISO 3166: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Apparently 3166-2 codes can have mixed letters and digits) |
No edit summary |
||
Line 14: | Line 14: | ||
local function strip(text) |
local function strip(text) |
||
text = string.upper(text) |
text = string.upper(text) --Case insensitivity |
||
text = string.gsub(text,"[%s%-%,%.]","") |
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 |
--text = string.gsub(text,"[\768-\879]","") --Unicode deaccenting doesn't work |
||
return text |
return text |
||
Line 22: | Line 23: | ||
local function findname(code,cdata,qry) |
local function findname(code,cdata,qry) |
||
local sqry = strip(qry) |
local sqry = strip(qry) |
||
if cdata["name"] and sqry==strip(cdata["name"]) |
if cdata["name"] and sqry==strip(cdata["name"]) |
||
⚫ | |||
return true |
|||
⚫ | |||
end |
|||
then |
|||
⚫ | |||
return true |
return true |
||
end |
end |
||
for _,tname in ipairs(cdata["altnames"] or {}) do |
for _,tname in ipairs(cdata["altnames"] or {}) do |
||
if sqry==strip(tname) then |
if sqry==strip(tname) then |
||
return true |
|||
end |
|||
end |
|||
if string.find(sqry,"^%u%u?%u?$") or string.find(sqry,"^%d%d?%d?$") then |
|||
⚫ | |||
return true |
return true |
||
end |
end |