C#正则表达式提取结果转DataTable
如题:假设原字符串为:
id=54552145,name=dgbgv,name2=gsygfyu,name3=bjhfd;
id=545462145,name=dgjhbv,name2=gfyhju,name3=bjfd;
id=54554652145,name=dgjhv,name2=gfyhju,name3=bvgfd;
id=54552436145,name=dgjhgv,name2=gshju,name3=bjhfd;
我想提取id,name1,name3
正则表达式:
id=(.*?),name=(.*?),name2=.*?,name3=(.*?);
请问怎么转成DataTable对象? 循环结果,添加到DataTable撒
参考:
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn() {ColumnName="name"},
new DataColumn() {ColumnName="sex"}
});
for (int i = 0; i < 10; i++)
{
DataRow row = dt.NewRow();
row["name"] = "zhangsan" + i;
row["sex"] = 22;
dt.Rows.Add(row);
}
页:
[1]