Hi, I've already read the article about string.sub() but I find it a bit confusing. Can someone explain this to me more clearly than the article so that I can have a better understanding, many thanks ????
Article about strings --> https://developer.roblox.com/en-us/api-reference/lua-docs/string
The first argument of string.sub() is usually referred to as the String
obviously, this is the string you will be using in string.sub().
The second argument of string.sub() is referred to as i and is the starting point for the string, this will then go to the third argument referred to as j which will return a string counting the character arguments i and j
-- > all vanilla string libaries.
-- > example usage:
local String = "WOW! YOU CAN DO THIS?" local i = 5 string.sub(String, i) -- no j argument, goes to end. -- > output: YOU CAN DO THIS?
-- > example of string.gsub() as asked in comments:
local String = "Hello, i don't like you!" local GSUB = string.gsub(String, "i don't like you!", "i like you!") print(GSUB) -- > output: Hello, i like you! -- > explain: -- > the first argument of string.gsub() is the string, the second is what you want to replace and the third is what you want to replace it with.
string.sub("String",Beginning number, End number)
example.
print (string.sub("Hello", 1, 3))
Output
"Hel"