for i,record in pairs(log) do
local labelText = string.lower(getLabelText(record))
if string.match(labelText, searchText) then
table.insert(newLog, record)
end
end
My problem is though, when users enter a magic character (^$()%.[]*±?) then I receive the following error:
Edit:
woot3 has confirmed that string.match lacks that parameter, and you should therefore use string.find for this, if you want to ignore magic characters.
For your purposes, you probably want to use string.find, it has an optional parameter that allows you to specify whether or not the pattern you use should be considered magic or not.
if labelText:find(searchText, 1, true) then
...
string.match does not have this optional parameter as it is specifically designed for pattern matching. You might still want to use this however, especially if you wish to allow certain magic characters to still be used. If you wish to strip out certain magic characters you can use string.gsub like so.
local sanitizedText = text:gsub("([%%%^%$%(%)%.%[%]%*%+%-%?])", "%%%1")
if labelText:match(sanitizedText) then
...