Jump to content




Compare character


  • You cannot reply to this topic
3 replies to this topic

#1 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 18 July 2013 - 04:49 PM

is there a way to compare a character in the middle of a string?
i'm making a search bar and it only shows the first character in the string when a search for it

Spoiler


#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 18 July 2013 - 04:58 PM

You could use string.find for that:
local entries = {
    "hello",
    "how",
    "does",
    "this",
    "work",
    "test"
}

local searchInEntries = function(key)
    -- * will return a table of entries which contain the key
    local result = {}
    for ixEnt = 1, #entries do if string.find(entries[ixEnt], key) then table.insert(result, entries[ixEnt]) end end
    return result
end
More at http://lua-users.org...LibraryTutorial

#3 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 18 July 2013 - 05:45 PM

Ive made the code. Lets say I was bored :)
Spoiler

Not sure if its always 100% correct!

#4 MR_nesquick

  • Members
  • 106 posts
  • LocationNorway

Posted 18 July 2013 - 05:51 PM

wow. thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users