获取介于1到100之间的数值 [英] Getting numerical value between 1 and 100

查看:80
本文介绍了获取介于1到100之间的数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中使用正则表达式仅获取1-100之间的数值...请向我提供正则表达式...

how to use regular expressions in asp.net for geting only numerical value between 1-100... pls provide me the regular expression ...

推荐答案

试试这个
^([0-9]|[0-9][0-9])



你好新居

以下代码可解决您的问题,
Hi shinju

Following code solve your problem,
string text = "123 plus 12 equal 135";
foreach (Match num in Regex.Matches(text, @"\d{1,3}"))
{
   int result = Convert.ToInt32(num.Value);
   if (result <=100)
        Console.WriteLine(result); // output : 12
}


--SJ


--SJ


这篇关于获取介于1到100之间的数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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