C#中怎么利用正则表达式检查数字

这篇文章将为大家详细讲解有关C#中怎么利用正则表达式检查数字,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

创新互联公司主要从事网站建设、做网站、网页设计、企业做网站、公司建网站等业务。立足成都服务如东,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

直接调用以下函数进行C#正则表达式数字检查,返回值为true表示输入是数字,反之不是。
itemvalue为输入的值。

C#正则表达式数字检查的代码

using system.text.regularexpressions;    private static bool isnumeric(string itemvalue)   {   return (isregex("^(-?[0-9]*[.]*[0-9]{0,3})$", itemvalue));   }    private static bool isregex(string regexvalue, string itemvalue)   {    try   {   regex regex = new system.text.regularexpressions.regex(regexvalue);   if (regex.ismatch(itemvalue)) return true;   else return false;   }   catch (exception )   {   return false;   }   finally   {   }   }

关于C#中怎么利用正则表达式检查数字就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


文章标题:C#中怎么利用正则表达式检查数字
当前路径:http://scyanting.com/article/pgsjcc.html