C# 正则表达式例子

                string strTempDistrictID = txtDistrictID.Text;

                //必须是[数字][数字][0000]格式
                Regex re = new Regex("^[0-9]{2}[0]{4}$");
                Match match = re.Match(strTempDistrictID);
                if (match.Success == false)
                {
                    MessageBox.Show("地区代码(省份代码)必须是 \"前两位必须是数字,后四位必须是零\" 的格式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtDistrictID.Focus();
                    return false;
                }

 

posted @ 2012-12-18 11:07  杨斌_济南  阅读(291)  评论(0编辑  收藏  举报