Lets say i have string ‘a’ which is “This is a string with /stringnamehere/ to replace”, I want to replace “/stringnamehere/” with whatever string that string holds; Question: how whould I do this?
Notes:
- ‘/’ is used to show the script that the string should be replaced.
- the problem is that stringnamehere is a variable and not a set string so i cant replace “/stringnamehere/” with “a string” becouse “/stringnamehere/” actually is “/”+stringnamehere+“/”.
What I want to achieve:
string a = "This is a string with /b/ to replace";
string b = "nothing";
string c;
//replace code
print(c);
output: "This is a string with nothing to replace"
I hope I made myself clear and I hope someone could help me.
[Edit]
there are 2 variable senteces, if one of them contains the name of the other between 2 "/"s then this will be replaced with what that variable holds;
string VariableString1 = "Nothing";
string VariableString2 = "VariableString1 holds : /VariableString1/ as value";
//output
Debug.Log(VariableString2) should be "VariableString1 holds : Nothing as value".
My main problem is that both strings are variables so i cannot simply change a set sentance with a set replacement like:
string Replacement = “this”;
string Change1ToThis = “Change 1 to this”;
//replace 1 with this
“Change this to this”;