I agree with Shaun. I would make a trigger that matches on a word, and then use Lua to lookup in a table. After all, table lookups are fast because they are hashed, whereas the trigger regular expression would have to try one after the other.
Quote:
if wordtable.wilcards[foo] == not nil do
This method still has the problem I mentioned before. "not nil" will evaluate to "true". Thus you would have to store true in each table item for that to work. Better (and shorter) is:
if wordtable.wildcards[1] then
-- blah blah
end -- if
The other problem here is the tedium of setting up the table, having to give a value to each item. One method is to make a numerically-indexed table, and convert to a keyed index table, like this:
wordtable = {
"Lorem", "ipsum", "dolor", "sit", "amet",
"consectetur", "adipisicing", "elit" ,
--- and so on
} -- end of wordtable
keyed_wordtable = {}
-- do this once - turn table into keyed table
for _, v in ipairs (wordtable) do
keyed_wordtable [v] = true
end
print (keyed_wordtable ["ipsum"]) --> true
print (keyed_wordtable ["occaecat"]) --> nil
The original "wordtable" is simply a list of words - however the disadvantage is you can't do a keyed lookup. The for loop iterates through that and builds a second table, this time with "true" as the value for each entry.
|