a bunch of.lua

Run Settings
LanguageLua
Language Version
Run Command
function string.split(inputstr, sep) if sep == nil then sep = "%s" end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, str) end return t end function getRidOfSpaces(_string) local emptyString = '' local split = string.split(_string, ' ') for a,b in pairs(split) do if b then emptyString = emptyString .. b end end return emptyString end function containsTerm(term1, term2) if term1 and term2 then local containsterm = false local _term1 = getRidOfSpaces(string.lower(term1)) local _term2 = getRidOfSpaces(string.lower(term2)) if _term1 == _term2 then containsterm = true end if string.find(_term1, _term2) or string.find(_term2, _term1) then containsterm = true end if string.match(_term1, _term2) or string.match(_term2, _term1) then containsterm = true end return containsterm end end local dataBase = {{term='burger king', title='Burger King', description='Burger King is a fast food chain with burgers.'}, {term='balls',title='BALLS',description='Balls is a funny word'}} function getTitle(term) for a,b in pairs(dataBase) do if containsTerm(term, b['term']) == true then local title = b['title'] return title end end end function getDescription(term) for a,b in pairs(dataBase) do if containsTerm(term, b['term']) == true then local description = b['description'] return description end end end function assertPrint(a, _string) if not a then print(_string) return end end
Editor Settings
Theme
Key bindings
Full width
Lines