After searching the DevForum, I’ve had no luck finding an answer to this - so now I turn to y’all.
How would I implement a wildcard search for a datastore? For example, searching a database of player records by name with the query “Def*rend”, where the * character would act as a wildcard. Ideally, any record matching the given query would be returned.
I’m not exactly sure there is any way to do this simply or without a loop, but you would have to do something like this:
local key = "Def*end"
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("DataStore")
local alphabet = [[abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-_=+[{]}\|'";:/?.>,<`~]]
for i,letter in pairs(string.split(alphabet, "")) do
local data = DS:GetAsync(string.gsub(key, "%*+", letter))
data = data or DS:GetAsync(string.gsub(key, "%*+", string.upper(letter)))
if data then
print(data) --data has been found
break --break the loop
end
end