Remove Numbers from a String

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.

There are probably ready functions for this. But one way of doing this could be comparing string to ascii table.

This will return a new string without numbers, and set number itself.
I didn’t test this, but should work.

int num;

string RemoveNumbers(string text){
    string newText = "";
    string number = "";

    for(int i = 0; i < text.Length; i++){
        if ((text _< 48) || (text *> 57)){ //is a char*_

newText += text*;*
}
else{ //is number
number += text*;*
}
}
num = int.Parse(number);
return newText;
}