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;
                }
原文地址:https://www.cnblogs.com/YangBinChina/p/2822901.html