怎么整只获得并删除在C#中的所有字符串 [英] how get integer only and remove all string in C#

查看:99
本文介绍了怎么整只获得并删除在C#中的所有字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能去除串并获得唯一的整数,



我有一个字符串(01 - ABCDEFG)



我需要得到(01)仅


解决方案

 输入= Regex.Replace (输入[^ 0-9] +的String.Empty); 


How can I remove the strings and get only integers?

I have a string ( 01 - ABCDEFG )

i need to get (01) only

解决方案

input = Regex.Replace(input, "[^0-9]+", string.Empty);

这篇关于怎么整只获得并删除在C#中的所有字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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