这篇文章将为大家详细讲解有关C#中怎么利用正则表达式检查数字,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
直接调用以下函数进行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#中怎么利用正则表达式检查数字就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。