Listlist = new List (); List list2 = new List (); string input="MBUPN1:Murugesan,Pandian,MBUPN2:Murugesan,Pandian,MBUPN3:Murugesan,Pandian"; string[] parts1 = input.Split(','); for (int str = 0; str < parts1.Length; str++) { if (parts1[str].Contains(":")) { list.Add(parts1[str]); } } foreach (string zz in list) { string[] len = zz.Split(':'); list2.Add(len[0].ToString()); } foreach (string K in list2) { Response.Write(K); }
Showing posts with label Spliting strings with multiple delimiter character. Show all posts
Showing posts with label Spliting strings with multiple delimiter character. Show all posts
Sunday, September 02, 2012
Split with multiple delimiter character
Recently I have received an excel file in which one column formatted the AD users in "ID:FirstName,LastName".
I need to split the string ID only from the above string.I spent couple of hours to do it generic collection / LinQ based.But finally I end up with the classic way of splitting the string.
Here is my workaround.
Subscribe to:
Posts (Atom)