你如何删除字符串中的所有字母字符? [英] How do you remove all the alphabetic characters from a string?
本文介绍了你如何删除字符串中的所有字母字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串containg字母字符,例如:
I have a string containg alphabetic characters, for example:
- 254.69米
- 26.56厘米
- 23.36英寸
- 100.85英尺
- 254.69 meters
- 26.56 cm
- 23.36 inches
- 100.85 ft
我想从上面提到的字符串中删除所有的字母字符(单位),这样我可以调用double.Parse()方法。
I want to remove all the alphabetic characters (units) from the above mentioned strings so that I can call the double.Parse() method.
推荐答案
这应该工作:
Regex.Replace(s, "[^0-9.]", "")
这篇关于你如何删除字符串中的所有字母字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文