Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/PHansen/Trunc
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!
-- Dec31-2014 -- Test af: sammensat_link = "{{URL|1=" .. hele_url .. "|2=" .. trunc_url .. "}}" -- ? -- https://en.wikipedia.org/wiki/Help:Lua_for_beginners -- Module:Sandbox/PHansen/Trunc testes via: User:PHansen/Trunc -- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.find -- Mulig forbedring med tabel der gennemløbes -- ? topdomaene = { ".da", ".no", "", "", "", "", "", "", "", "", "", "", "", } ? for usikker ? -- topdomaene_slash = { ".da/", ".no/", "", "", "", "", "", "", "", "", "", "", "", } -- og så et for-loop ? -- for k, v in pairs(arr) do -- print(k, v[1], v[2], v[3]) -- end -- hvordan at implementere? -- for k, v in pairs(arr) do -- if at_finde = v[k] -- end local p = {} -- defines a variable p as an empty table, but *not* nil. topdomaene_slash = { ".da/", ".no/"} text = "Hello world" at_finde = ".dk/" -- "el" fra tidligere test at_finde2 = ".dk" -- "el" fra tidligere test hele_url = "http://www.tryggevaeldeprovsti.dk/" trunc_url = "www.tryggevaeldeprovsti.dk" sammensat_link = "" -- return_link = "{{URL|1=tryggevaelde.dk|2=tryggev.dk}}" var OK, men hvad med variable -- return_link = {{URL|1=hele_url|2=trunc_url}} -- NEGATIVE - tolker det bogstaveligt, ej som variabel --function p.main( frame ) -- this block defines the table element p[main] as the _function_ listed below -- return "Hello world" -- the string result --end -- ends the block defining p.main function p.main( frame ) -- this block defines the table element p[main] as the _function_ listed below --[[ if string.len(text) < 15 then --<<<<<<<<<<<<<<<<<<<<< nil ? return ("Under 15") else return text -- the string result end --]] -- test af string.find -- if string.find( text, 'el', '1', plain ) ~= nil then -- her er text en variabel -- if string.find( text , at_finde , '1' , plain ) ~= nil then -- her er source og target variable if string.find( hele_url , at_finde , '1' , plain ) or string.find( hele_url , at_finde2 , '1' , plain ) ~= nil then --sammensat_link = "{{URL|1=" .. hele_url .. "|2=" .. trunc_url .. "}}" -- ? sammensat_link = "[" .. hele_url .. " " .. trunc_url .. "]" -- er det bedre ? Jan05-2015 return_link = sammensat_link return (return_link) else return 'Negativ : fandt det ikke' end end -- ends the block defining p.main return p -- this returns the table p, which contains function p.main, which returns string "Hello world"
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/PHansen/Trunc/doc
(
edit
)