首页 > 其他 > 详细

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

时间:2018-11-18 15:46:39      阅读:169      评论:0      收藏:0      [点我收藏+]

实现效果:

技术分享图片

知识运用:

技术分享图片

 

代码实现:

        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}$");
        }

  

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!