Hi
In excel i have one column Age . It has value - 11.2 years
i want only 11.2 , i want to remove any alphabetic values .
Thanks
Hi
In excel i have one column Age . It has value - 11.2 years
i want only 11.2 , i want to remove any alphabetic values .
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Apr 13, 2023, 2:25 AM EDT
Hello Ramco,
Use regex as below:
string age = "11.2 years"; // Use regular expression to extract numerical value string numericalValue = Regex.Match(age, @"[-]?\d+(\.\d+)?").Value; Console.WriteLine(numericalValue);Thanks
Naimish Makwana
Rafnas T PRank #280 · 8.8K reputationPosted Apr 13, 2023, 2:30 AM EDT
I think you have one space after age value after that you added 'years' right, then you can do that cell value.ToString().split(' ')[0]; to get first before space value.
Hope it will be helpfull to you.