What are all the weird codes in string.gsub and how do I use them?

So I have seen people use like string.gsub("%d","#") and some other things in a lot of scripts. But as of using LuaU for more than a year now I still don’t know what is their purpose and would like to see a reply here that can help me memorize them. After that can someone also tell me what string.format() is?

This article here should explain what they are:

https://python-reference.readthedocs.io/en/latest/docs/str/formatting.html

Ik it says for python, but it is exactly the same in lua


string.format() recieves a string, then puts any parameters you add into it:

string.format("Hello there %s", "steve")
would result in: Hello there steve

so like its used to join stuff?

and yea ik lua is mostly made up of python but thanks anyways!

arent there any other roblox docs that shows the same thing but easier to understand? cause thats kinda hard

Maybe give this a go:

i also found this one! lol String Patterns

1 Like

Thank you that explains a lot to me about string.format! Have a good day!

That’s the right one when you’re using gsub. Those other articles are about formatting, which is different.

https://www.lua.org/pil/20.1.html
https://www.lua.org/pil/20.2.html
https://www.lua.org/pil/20.3.html
https://www.lua.org/pil/20.4.html