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:

enter image description here 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

Popular posts from this blog

java - Unable to make sub reports with Jasper -

Save and close a word document by giving a name in R -

scala - play framework: Modules were resolved with conflicting cross-version suffixes -