首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

为何正则表达式不能判断呢?(续)

2012-09-29 
为什么正则表达式不能判断呢?(续)刚才的帖子结了,重新起个新的。C# codeusing Systemusing System.Collect

为什么正则表达式不能判断呢?(续)
刚才的帖子结了,重新起个新的。

C# code
using System;using System.Collections.Generic;using System.Text.RegularExpressions;using System.Linq;using System.Text;namespace homework1._3{    class Program    {        static void isvalidzipcode(ref int a, out string b,out string c)        {            a = 11111;            b ="-CCCC";            c = a + b;        }        static void Main(string[] args)        {            int val=0;            string str1,str2;            Regex reg = new Regex(@"^\d{5}-([a-zA-Z]){4}$");            isvalidzipcode(ref val, out str1,out str2);            Match mm = reg.Match(str2);            Console.WriteLine("{0}", str2);            Console.WriteLine(mm);            Console.ReadLine();        }    }}

本意是内设一个11111-CCCC,先输出这个,然后第二行判断格式是否正确(前五位数字,第六位是横杠,最后四位是字母)

应该输出如下:
11111-CCCC
True

现在输出的两行都是11111-CCCC
请问哪里有问题了?

[解决办法]
[color=#FF0000]
C# code
Console.WriteLine(mm.Success) 

热点排行