Click here to Skip to main content
15,891,923 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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];
Posted
Updated 3-Sep-16 22:15pm
v2
Comments
Tomas Takac 4-Sep-16 3:30am    
I don't understand. You clearly are able to split the strings. So what is the problem?
Karthik_Mahalingam 5-Sep-16 6:52am    
what you are trying to do?
is this
string [] st=time="2016-08-28 14:04:32" id="8888" name="Manik" workcode="0" status="0"

a string?
AB Masud 7-Sep-16 21:25pm    
Already Solved

1 solution

Use a regex:
C#
public static Regex regex = new Regex(
      "time=\\\"(?<Time>.+?)\\\"+?\\s+\r\nid=\\\"(?<ID>.+?)\\\"\\s+\r\n"+
      "name\\=\\\"(?<Name>.+?)\\\"\\s+\r\nworkcode\\=\\\"(?<Workcode>"+
      ".+?)\\\"\\s+\r\nstatus\\=\\\"(?<Status>.+?)\\\"",
    RegexOptions.Multiline
    | RegexOptions.IgnorePatternWhitespace
    | RegexOptions.Compiled
    );

You can then extract the parts you need by name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900