首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

取字符串中的数字解决方案

2012-01-06 
取字符串中的数字C#如何利用正则表达式取出字符串中的数字例如:stringstr AAA123BB 现在要取出123[解

取字符串中的数字
C#如何利用正则表达式取出字符串中的数字
例如:string   str= "AAA123BB ";
现在要取出123

[解决办法]
try

string str = "AAA123BB ";
string result = string.Empty;
Match m = Regex.Match(str, @ "\d+ ");
if (m.Success)
{
result = m.Value;
}

热点排行