Class for looping every Character of string
-
Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra
-
Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra
-
Hi all, i am new to this ASp.net 2.0(C#) programming. I need a class which loops through every Character of a given String and basket them as two seperate string variable by the following. One basket will collect only input string start from a to g and the other collect h to z character. for eg: microsoft is the input string. in that first basket it will have "cf" and in the second basket it will have "mirosot". With Regards, Chitra
You can use a regular expression to match the characters. Call Regex.Replace with a delegate that will store away each matched character and replace it with an empty string. Something like:
string second = string.Empty; string first = Regex.Replace(text, "[a-z]+", delegate(Match m){ second += m.Value; return string.Empty; } );
If the string might be large, a StringBuilder would be better for collecting the characters.--- single minded; short sighted; long gone;