Question by
finlay_morrison · Jul 28, 2017 at 10:16 AM ·
intremovestrings
How to remove parts from a string
So basically lets say i have a string "Level_01" if i just wanted to keep the "01" in a string, or preferably in an int variable how would this be done.
Comment
Unity just borrowed C# for writing scripts. It's a real program$$anonymous$$g language used for lots of things, with lots of beginners asking Qs. You could search for just "C# find part of string" (or "find number in string" or something like that,) and get many answers that work the same in Unity.
Best Answer
Answer by acer777 · Jul 28, 2017 at 10:27 AM
Hey you would need to use a string split.
string[] x = "Level_01".split('_');
This way you could display the values in the array as:
x[0] = "Level"
x[1] = "01"
Hope this is what you was looking for.
Also you could use "Level_01".Replace("Level_", string.Empty);