I want to split this line:
string line = \"First Name ; string ; firstName\";
into an array of their trimmed versions:
\"Fi
Use Regex
string a="bob, jon,man; francis;luke; lee bob";
String pattern = @"[,;\s]";
String[] elements = Regex.Split(a, pattern).Where(item=>!String.IsNullOrEmpty(item)).Select(item=>item.Trim()).ToArray();;
foreach (string item in elements){
Console.WriteLine(item.Trim());
Result:
bob
jon
man
francis
luke
lee
bob
Explain pattern [,;\s]: Match one occurrence of either the , ; or space character