Unity C# Replace String.Split

Hi,

I have a string with this format “10,2/20,5/50,3”

Those are wins of every player.
“roomPrize,wins/nextRoomPrize,wins” etc

I figured out how to read it but I want to change the amount of wins for some roomPrize. I’ve come this far.

winsRawData = getStatW.text; //That is the wins string formated as explained above

    string[] winSplits = winsRawData.Split('/');

    for(int i = 0; i < winSplits.Length; i++)
    {
        if(winSplits*.Split(',')[0] == room.ToString()) //room is the roomPrize that i want to affect*

{
//newWins is the new win count that I want to update with
//winSplits*.Split(‘,’)[1] == newWins; ← I just need to do that*
}
}
Thanks

You don’t need to split the line once you’ve find it, you have all the data to just replace it entirely:

winSplits *= room + "," + newWins;*

Once your loop is finished you can then build the final string by joining together everything in winSplits.