# String wont replace after using Replace

**URL:** https://discussions.unity.com/t/string-wont-replace-after-using-replace/535759
**Category:** Scripting
**Tags:** Scripting
**Created:** [April 24, 2014, 7:07am UTC](https://discussions.unity.com/t/string-wont-replace-after-using-replace/535759 "2014-04-24T07:07:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![light766](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/light766/32/221372_2.png) [@light766](https://discussions.unity.com/u/light766)
#### Post date: [April 24, 2014, 7:07am UTC](https://discussions.unity.com/t/string-wont-replace-after-using-replace/535759/1 "2014-04-24T07:07:46Z")

</div>

been debugging this for quite some time and still cant find a solution, the text is adding the ";"s and removes them in the end, the problem here is that the Replace is not replacing, so at the end the text remains the same. 😵‍💫

```auto
public void SomeoneLeft(string user){
	
		if(photonView.isMine){
			print (user);

			teamOneText += ";";
			teamOneText = ";" + teamOneText;
			teamOneText.Replace(";" + user + ";",";;");
			teamOneText = teamOneText.Substring(0, teamOneText.Length - 1);
			teamOneText = teamOneText.Substring(1);

			teamTwoText += ";";
			teamTwoText = ";" + teamTwoText;
			teamTwoText.Replace(";" + user + ";",";;");
			teamTwoText = teamTwoText.Substring(0, teamTwoText.Length - 1);
			teamTwoText = teamTwoText.Substring(1);
		}

	}

```

---

<div class="post-metadata">

### Author: ![devandart](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/devandart/32/591734_2.png) [@devandart](https://discussions.unity.com/u/devandart)
#### Post date: [April 24, 2014, 7:15am UTC](https://discussions.unity.com/t/string-wont-replace-after-using-replace/535759/2 "2014-04-24T07:15:48Z")

</div>

The Replace() method returns the replaced string like Substring reuturns a substring, so you have to write

```auto
teamOneText = teamOneText.Replace(";" + user + ";",";;");

```

cheers

---

<div class="post-metadata">

### Author: ![light766](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/light766/32/221372_2.png) [@light766](https://discussions.unity.com/u/light766)
#### Post date: [April 24, 2014, 7:19am UTC](https://discussions.unity.com/t/string-wont-replace-after-using-replace/535759/3 "2014-04-24T07:19:25Z")

</div>

yup, I just found that out, haha i feel so stupid, but thanks man!
