This topic has been partially handled before by another user in thread: Lua string.gsub with Multiple Patterns
I'm having issues and I believe it is with my pattern (second) argument. Here is my example of the gsub code I'm trying to use:
local dateCode = "MMM/dd-YYYY:ss"
--dateCode = dateCode:gsub(".*", {["%/"] = "s", ["%-"] = "n", ["%:"] = "c"}) --original code but removed after @Etan's comments.
dateCode = dateCode:gsub(".*", {["/"] = "s", ["-"] = "n", [":"] = "c"})
print(dateCode)
MMM/dd-YYYY:ss --printed
MMMsddnYYYYcss --desired
I believe that I shouldn't be looking over all characters like I currently have it, but I'm not sure what pattern I should be using for the dateCode variable.
The idea is to replace the keys with the first alpha character that it begins with.
MMMsddnYYYYcss? The keys in thegsubreplacement need to equal the captured bits of the string that the pattern matches. You don't have%in your input so none of your keys can possibly match.%as escape characters in my keys. Thanks. Once removed, still does not appear to provide the desired result.gsublooks up in the table argument. So if you want to replace just those characters then you need to, individually, match just those characters.%p...... I'll update my post to show the correct pattern.