Hiya, so I’m currently trying to figure out how to make it so that it replaces multiple characters to another character, in this case “•”.
So for example, 1234 would turn into ••••
Does anyone know how to do this?
Hiya, so I’m currently trying to figure out how to make it so that it replaces multiple characters to another character, in this case “•”.
So for example, 1234 would turn into ••••
Does anyone know how to do this?
Here’s a demo code that shows you how to do it with string:gsub
:
Also, I don’t know if you only want to change numbers, but this script makes both numbers and letters to dots.
local originalString = "hello 123 world"
local maskedString = originalString:gsub("[%a%d]", "•")
print(maskedString) -- Prints "••••• ••• ••••"
If you want to only change numbers, you can change `[%a%d] to just %d which stands for digits 0-9 or you can use just %a which are for letters.
Hope this helps, and feel free to ask if you need more help!
That is EXACTLY what I was looking for! Thanks alot!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.