Hi. I need to remove some numbers from a string.
The string looks something like “XX points”, where XX is a number. It can be one or two digits.
I tried things with character arrays and such, but I can’t get anything to work. Here’s the code I’m working on now (it says that the debug.log returns “array index is out of range” error messages).
if (MainBallPoints != null)
{
string ballvalue = string.Empty;
string currentvalue = MainBallPoints.value.ToString();
for (int i = 0; i < currentvalue.Length; i++)
{
if (((int)currentvalue _>= 0) && ((int)currentvalue *<= 9))*_
{
ballvalue += currentvalue*;*
}
}
Debug.Log(ballvalue[1]);
Utility.MainBallScore = int.Parse(ballvalue);
Debug.Log(Utility.MainBallScore);
}
Any advice is very welcome. I also don’t feel comfortable casting inside of a for loop, but I’m not sure of a way around that.
Thank you for your time.