How do you remove all the alphabetic characters from a string?

后端 未结 6 1588
时光说笑
时光说笑 2020-12-24 10:18

I have a string containg alphabetic characters, for example:

  1. 254.69 meters
  2. 26.56 cm
  3. 23.36 inches
6条回答
  •  没有蜡笔的小新
    2020-12-24 10:59

    Using LINQ:

    using System.Linq;
    
    string input ="57.20000 KG ";
    string output = new string(input.Where(c=>(Char.IsDigit(c)||c=='.'||c==',')).ToArray());
    

提交回复
热议问题