我一直在寻找一段时间以弄清楚如何确认字符串以数字开头。我遇到了一个正则表达式语句'/^\d/',我可以确认它是否以数字开头。但是我似乎无法让它在下面的代码中工作。我在声明中哪里出错了if(Regex.Match(info,"/^\d/"))
?
//String attachbody is the attachment body from an email C read into a string
string[] data = Regex.Split(attachbody, "\n");
foreach (String info in data)
{
if (Regex.Match(info,"/^\d/"))
{
string[] tabbedHeaderData = Regex.Split(info, "\t");
TicketID = tabbedHeaderData[0].ToString();
Status = tabbedHeaderData[1].ToString();
URL = tabbedHeaderData[2].ToString();
InitCats = tabbedHeaderData[3].ToString();
PostRevCats = tabbedHeaderData[4].ToString();
ListNumClosed = tabbedHeaderData[5].ToString();
Console.WriteLine(TicketID);
Console.WriteLine(Status);
Console.WriteLine(URL);
Console.WriteLine(InitCats);
Console.WriteLine(PostRevCats);
Console.WriteLine(ListNumClosed);
Console.ReadLine();
}
}
示例数据(制表符分隔):
TicketID 状态 URL InitCats PostRevCats ListNumClosed 555555 Closed http://5555555.com/searcho Malicious Sites 55555