i wanna split the string using the vertical bar spliter ( || - pipe delimiter). in my string, this delimiter occurs 4 times, which means, i have to get the result as string array[3]. but i am getting string array[7]. where it adds an empty array between
every string which is splitted already..
For example, my code is lik
string temp = "INDIA || is || a || Developing || Country";
string[] arTemp = temp.split("||".ToCharArray());
in the above code, my result should be wounded until arTemp[3], coz, string is splitted into 4 parts. but, i am getting arTemp[9]. Between each splitter array string it is adding one empty string, except for the last string.
output is coming like
arTemp[0] = "INDIA"
arTemp[1] = ""
arTemp[2] = "is"
arTemp[3] = ""
arTemp[4] = "a"
arTemp[5] = ""
arTemp[6] = "Developing "
arTemp[7] = ""
arTemp[8] = "Country"
How to remove the empty spaces in between the array stringS??
abivenkat
Member
50 Points
97 Posts
string split Delimiter doubt
May 05, 2012 12:59 PM|LINK
hi all,
i wanna split the string using the vertical bar spliter ( || - pipe delimiter). in my string, this delimiter occurs 4 times, which means, i have to get the result as string array[3]. but i am getting string array[7]. where it adds an empty array between every string which is splitted already..
For example, my code is lik
string temp = "INDIA || is || a || Developing || Country";
string[] arTemp = temp.split("||".ToCharArray());
in the above code, my result should be wounded until arTemp[3], coz, string is splitted into 4 parts. but, i am getting arTemp[9]. Between each splitter array string it is adding one empty string, except for the last string.
output is coming like
arTemp[0] = "INDIA"
arTemp[1] = ""
arTemp[2] = "is"
arTemp[3] = ""
arTemp[4] = "a"
arTemp[5] = ""
arTemp[6] = "Developing "
arTemp[7] = ""
arTemp[8] = "Country"
How to remove the empty spaces in between the array stringS??
thanks,
abivenkat