How do you make a search box that can look through a table without needing the whole name? Eg. if you type "alpha" it would show everything that starts with "alpha" like "Alpha" and "Alphabet" depending on whatevers in the table. Thanks
Note, I'm not looking for someone to write the script - even a wiki link would be handy as all I've found was people talking about web features. Thanks
String.match is great in situations like this.
01 | words = { "Test1" , "Test3" , "sdfdsf" , "sdtgr" } |
02 |
03 | for i,v in pairs (words) do |
04 | local checkMatch = string.match(v, "sd" ) |
05 |
06 | if checkMatch then |
07 | print (v.. " matches with sd!" ) |
08 | else |
09 | print (v.. " doesn't match with sd!" ) |
10 | end |
11 | end |
In the code above we have a table containing four strings. Once we declare the table we loop through it and check if the item in the table we're checking currently has "sd" in it. If that's the case we print that it does match with sd. If not, we print it doesn't match with it.