i have this C# code that i found and then improved upon for my needs, but now i would like to make it work for all numeric data types.
public static int[] intRemover (string input)
{
string[] inputArray = Regex.Split (input, @"\D+");
int n = 0;
foreach (string inputN in inputArray) {
if (!string.IsNullOrEmpty (inputN)) {
n++;
}
}
int[] intarray = new int[n];
n = 0;
foreach (string inputN in inputArray) {
if (!string.IsNullOrEmpty (inputN)) {
intarray [n] = int.Parse (inputN);
n++;
}
}
return intarray;
}
This works well for trying to extract whole number integers out of strings but the issue that i have is that the regex expression i am using is not setup to account for numbers that are negative or numbers that contain a decimal point in them. My goal in the end like i said is to make a method out of this that works upon all numeric data types. Can anyone help me out please?
intdatatype then. Perhaps usedecimal. Unfortunately my Regex isn't up to scratch so I cannot help you with an answer