剔除字符串中的非数字字符 [英] Stripping out non-numeric characters in string

查看:151
本文介绍了剔除字符串中的非数字字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿进出口寻找在ASP.NET C#

Hey Im looking to strip out non-numeric characters in a string in ASP.NET C#

所以,即40595 P.A。

So i.e 40,595 p.a.

最终会与40595

感谢

推荐答案

有很多种方法,但是这应该做的(不知道它是如何与真正的大串执行虽然):

There are many ways, but this should do (don't know how it performs with really large strings though):

private static string GetNumbers(string input)
{
    return new string(input.Where(c => char.IsDigit(c)).ToArray());
}

这篇关于剔除字符串中的非数字字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆