110,534
社区成员
发帖
与我相关
我的任务
分享
string inputStr="";
if(Regex.Matches(inputStr,"\d+").Count==3&®ex.Matches(inputStr,"[-]").Count==2)
{
//满足条件了
}
public static bool ValidateData(string data)
{
string[] array = data.Split(',');
if (array.Length == 5)
{
int count1 = 0, count2 = 0;
foreach (string s in array)
{
double test;
if (count2 == "-") count2++;
else if (double.TryParse(s, out test)) count1++;
else break;
}
return count1 == 3 && count2 == 2;
}
return false;
}