C# .NET - How can I split string with a tab separator? -
i have string in code:
string test = @"aaaaa aaaaa aaaaa bbbb ttttt tttttt 33333 44444 777777 77777 88888 8888 8888 88888 88888 wwwww wwwww wwwwww wwwww wwwww wwwwww";
and here code spliting string new line character , tab.
foreach (var line in test.split(new string[] { environment.newline }, stringsplitoptions.none)) { foreach (var lineitem in line.split('\t')) { } }
in first interation of first loop line variable "aaaaa aaaaa aaaaa bbbb ttttt tttttt" , correct, in seconds loop first interation variable lineitem same, doesn't split string tab separator. why it's happening?
the reason not work because tabs
not tabs in string test
- see this:
first line generated myself ms excel. use regex correctly represent whitespace char (even unicode escape sequences)
regex regex = new regex(@"\s"); string[] bits = regex.split(line);
Comments
Post a Comment