码迷,mamicode.com
首页 > 其他好文 > 详细

使用正则表达式验证两位小数

时间:2018-11-18 16:08:04      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:str   sage   har   正则   text   分享图片   技术分享   http   val   

实现效果:

技术分享图片

知识运用:

技术分享图片

 

代码实现:

        private void button1_Click(object sender, EventArgs e)
        {
            if (IsValidate(textBox1.Text.ToString()))
                MessageBox.Show("验证通过","提示:");
            else
                MessageBox.Show("验证失败", "提示:");
        }
        //方法定义
        public bool IsValidate(string str_decimal) {
            return System.Text.RegularExpressions.
                Regex.IsMatch(str_decimal,@"^[0-9]+\.[0-9]{2}$");
        }

  

使用正则表达式验证两位小数

标签:str   sage   har   正则   text   分享图片   技术分享   http   val   

原文地址:https://www.cnblogs.com/feiyucha/p/9978034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!