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 - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -