split a string into parts by losing no character in c#
-
hello forum i am spliting a string into parts on the occurance of characther a by using split method like
string a = "advanced";
string[] b = new string[10];
b=a.Split('a');but by this method i m losing character a from the string array it is returning
b[0]=
b[1]=dv
b[2]=ncedi want to get
b[0]=a
b[1]=dv
b[2]=a
b[3]=ncedcan any body help me regards rahul adya
-
hello forum i am spliting a string into parts on the occurance of characther a by using split method like
string a = "advanced";
string[] b = new string[10];
b=a.Split('a');but by this method i m losing character a from the string array it is returning
b[0]=
b[1]=dv
b[2]=ncedi want to get
b[0]=a
b[1]=dv
b[2]=a
b[3]=ncedcan any body help me regards rahul adya
-
hello forum i am spliting a string into parts on the occurance of characther a by using split method like
string a = "advanced";
string[] b = new string[10];
b=a.Split('a');but by this method i m losing character a from the string array it is returning
b[0]=
b[1]=dv
b[2]=ncedi want to get
b[0]=a
b[1]=dv
b[2]=a
b[3]=ncedcan any body help me regards rahul adya
rahuladya wrote:
string[] b = new string[10]; b=a.Split('a');
Why do you create an array and assign to the b variable, when you are assigning a new variable to it on the next line?
rahuladya wrote:
i want to get b[0]=a b[1]=dv b[2]=a b[3]=nced
You can use a regular expression to split the string:
string a = "advanced";
string[] b = Regex.Split(a, "(a)");Or for any string you like:
string a = "advanced";
string splitter = "a";
string[] b = Regex.Split(a, "(" + Regex.Escape(splitter) + ")");Despite everything, the person most likely to be fooling you next is yourself.
-
rahuladya wrote:
string[] b = new string[10]; b=a.Split('a');
Why do you create an array and assign to the b variable, when you are assigning a new variable to it on the next line?
rahuladya wrote:
i want to get b[0]=a b[1]=dv b[2]=a b[3]=nced
You can use a regular expression to split the string:
string a = "advanced";
string[] b = Regex.Split(a, "(a)");Or for any string you like:
string a = "advanced";
string splitter = "a";
string[] b = Regex.Split(a, "(" + Regex.Escape(splitter) + ")");Despite everything, the person most likely to be fooling you next is yourself.
-
rahuladya wrote:
string[] b = new string[10]; b=a.Split('a');
Why do you create an array and assign to the b variable, when you are assigning a new variable to it on the next line?
rahuladya wrote:
i want to get b[0]=a b[1]=dv b[2]=a b[3]=nced
You can use a regular expression to split the string:
string a = "advanced";
string[] b = Regex.Split(a, "(a)");Or for any string you like:
string a = "advanced";
string splitter = "a";
string[] b = Regex.Split(a, "(" + Regex.Escape(splitter) + ")");Despite everything, the person most likely to be fooling you next is yourself.