- Home /
Replace String
So I searched around and was unable to find anything talking about this. The manual seems to have nothing on it (at least that I could find). I want to use the replace command to... well replace. Does anyone know where I can find a page detailing it's use? I seriously couldn't find anything I don't know if I'm just dumb or what but I'm lost.
Hi, I also haven't found it in the manual. What do you need to do exactly?
Answer by spilat12 · May 27, 2018 at 09:14 PM
Here is the documentation for the String.Replace method. Note that it doesn't change the existing string, it creates a new string with applied modifications. Here's the official definition:
"Returns a new string in which all occurrences of a specified Unicode character or String in the current string are replaced with another specified Unicode character or String"
Simple code example:
string text = "Hello, World!";
void Start()
{
text = text.Replace("Hello", "What's up");
Debug.Log(text);
//output: "What's up, World!"
}
Thank you for the help! This makes it much clearer!
You are welcome and good luck with your project! :)