Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to replace every single character in a string with a certain character?

Hi. I would like to know how I could replace a string with a character?

For example, I have a string: "Hello, this is a string"

What if I wanted to replace every single character in the string with an underscore? It would be like: "______ ____ __ _ ______"

How would I put that into a script?

I don't really know much about string manipulation. Thanks!

2 comments

0

Like admin commands?

0

Kind of? yeah

1 answer

✓ Accepted answer

You can use regex to replace the characters, like "[%a%p%c]", you will just plug it in gsub and it will work. Example:

local FilterCharacter = "_"

local String = "Wow, I'm a string"
local FilteredString = string.gsub(String, "[%a%p%c]", FilterCharacter)
print(FilteredString)

This discussion is preserved as it was. New answers, comments, and votes are closed.