问题描述
string [] st = time =2016-08-28 14:04:32id =8888name =Manikworkcode =0status =0
如何分开数据?
time = 2016-08-28 14:04:32;
id = 8888;
name = Manik;和workcode = 0;
如何解决这个问题并保存到数据库???
AB Masud
我的尝试:
char [] splitchar = {'='};
label1.Text = strArr [0];
label2.Text = strArr [1];
label3.Text = strArr [2];
label4.Text = strArr [3];
label5.Text = strArr [4];
label6.Text = strArr [5];
label7。 Text = strArr [6];
label8.Text = strArr [7];
label8.Text = strArr [8];
使用正则表达式:
public static Regex regex = new 正则表达式(
time = \\\(?< Time>。+?)\\\ +?\\\\ + \\\\\ = = \\\(?< ID>。+?)\\\ \\\\ + \\\\ n +
name \\ = \\\(?< Name>。+?)\\\ \\\\ + \\\\\\\\\ span>(?< Workcode> +
。+?)\\\ \\\ \\\\ + \\\\\\\ = = \\\(?< Status> ;。+?)\\\ ,
RegexOptions.Multiline
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);
然后,您可以按名称提取所需的部分。
string [] st=time="2016-08-28 14:04:32" id="8888" name="Manik" workcode="0" status="0"
how to separate data ?
time=2016-08-28 14:04:32;
id=8888;
name=Manik; and workcode=0;
how to solve this problem and save to database???
AB Masud
What I have tried:
char[] splitchar = { '=' };
label1.Text = strArr[0];
label2.Text = strArr[1];
label3.Text = strArr[2];
label4.Text = strArr[3];
label5.Text = strArr[4];
label6.Text = strArr[5];
label7.Text = strArr[6];
label8.Text =strArr[7];
label8.Text = strArr[8];
这篇关于String []插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!