日期:2014-05-20 浏览次数:20901 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] yourstr = new string[] { "1,2,3", "1,2,-3", "1-2-3","dd.dd" };
Regex re = new Regex(@"^(\d+[,-])*\d+$");
foreach (string s in yourstr)
{
Console.WriteLine("{0} {1}",s,re.Match(s).Success);
}
}
}
}