I know this is dumb but I do not know how to use string.gsub whatsoever all I know about it is it can be used on strings. So I have looked everywhere and there was no good info I could fine. I would love to know how to use string.gsub/:gsub please. I do not understand why people add stuff like "+%*" or "%@)"
local MyMessage = "My message Test"
--// I do not know the rest
The basic usage of it would be when you have a string and want to change some word/letter in it to something else. In this case i have a string “Hello Kid!”, i want to change the word “Kid” to “World”. Its done like this
local String = "Hello Kid!"
local newstring = string.gsub(String, "Kid", "World")
print(newstring) -- prints - Hello World!
There also other things you can do with it, but i’m not using it so widely so i can’t help with explaining those.
String patterns can be pretty confusing, but that is a character class, bascially, a set of characters you search for.
%d+
This pattern in particular will do 2 things. %d states that you should look for any digits in a specific string. The + modifier states that the character class should match 1 or more of said class.
The developer API has a page on this, its a good read.