HI everyone,
i have to split a string like "CD-016 - Samina Joshi" into string1="CD-016 " and string2="Samina Joshi". how is it possible to do.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Praneeth KumarRank #4,422 · 344 reputationPosted Jun 12, 2011, 11:11 PM EDT
string str = "CD-016 - Samina Joshi";
string str1 = str.Substring(0, str.IndexOf(" - "));
string str2 = str.Substring(str.IndexOf(" - ") + 3, str.Length - str.IndexOf(" - ") - 3);
Suthish NairRank #92 · 22.8K reputationPosted Jun 13, 2011, 12:23 AM EDT
string[] lines = System.Text.RegularExpressions.Regex.Split("CD-016 - Samina Joshi", " - ");
Praneeth KumarRank #4,422 · 344 reputationPosted Jun 13, 2011, 12:24 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 13, 2011, 12:27 AM EDT
string[] items = str.Split(new string[]{" - "}, StringSplitOptions.None);
Suthish NairRank #92 · 22.8K reputationPosted Jun 13, 2011, 1:37 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 13, 2011, 2:19 AM EDT