Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/trappist the monk/ac code
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict'); local p={} function p.ac_code (frame) local page = mw.title.getCurrentTitle(); -- get a page object for this page local content = page:getContent(); -- get unparsed content local out_table = {}; -- table assembled tables local wiki_name; local icao; for iata, iata_name in string.gmatch (content, "p%.IATA%['(%u%u%u)'%]='([^\n\r]-)'") do -- for each iata airport code line, get the code and airport name local temp_table = {}; wiki_name = mw.ustring.match (content, "p%.WikiName%['" .. iata .. "'%]='([^\r\n]+)'"); -- get the wiki article name that matches iata code local name = mw.ustring.gsub (iata_name, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ) icao = mw.ustring.match (content, "p%.ICAO%['(%u%u%u%u)'%]='" .. name .. "'"); -- get the icao code that matches the iata airport name if not icao then icao = '' end table.insert (temp_table, '{'); table.insert (temp_table, table.concat ({"'" .. iata .. "'", "'" .. icao .. "'", "'" .. mw.text.trim(iata_name) .. "'", "'" .. mw.text.trim(wiki_name) .. "'"}, ', ')); table.insert (temp_table, '}'); table.insert (out_table, table.concat (temp_table)); end return "<br /><pre>return {<br />	" .. table.concat (out_table, ',<br />	') .. "<br />	}<br />" .. "</pre>"; end return p;
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/trappist the monk/ac code/doc
(
edit
)