Jump to content

  • Log In with Google      Sign In   
  • Create Account


Tab Split String Now Working.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 athono   Members   -  Reputation: 132

Like
0Likes
Like

Posted 18 August 2012 - 01:40 AM

Tab Split String Now Working.

Please Help. I wrote a C# program that reads code one line at a time. Each line has data seperated by tabs.

Here is what my C# code is supposed to do. The line is supposed to be split into a string array by using the "Split" string methodIt is supposed to be spit read in text one line at a time and I use the "Split" method to group the line according to the tab character.

But, as this screen shot shows, it does not work. Any idea why?

Posted Image

Sponsor:

#2 RulerOfNothing   Members   -  Reputation: 1160

Like
0Likes
Like

Posted 18 August 2012 - 03:50 AM

Are you sure that the input text has tabs? How was the input text constructed?

#3 athono   Members   -  Reputation: 132

Like
0Likes
Like

Posted 18 August 2012 - 01:21 PM

Are you sure that the input text has tabs? How was the input text constructed?

How wierd. It looks like a text editor replaced the tabs with spaces without my say-so.

#4 phantom   Moderators   -  Reputation: 7108

Like
0Likes
Like

Posted 18 August 2012 - 02:36 PM

Depending on the text editor used some have an option to replace tabs with spaces; check to see if that option is selected.

#5 thok   Members   -  Reputation: 684

Like
0Likes
Like

Posted 18 August 2012 - 02:53 PM

If you want a more bullet-proof way to handle this (in case the spacing is a tab, 4 spaces, 8 spaces, 3 spaces, 1 space, whatever), you could instead do a regular expression split on whitespace.

I'm not a C# guy, but this looks like something you could use:
http://msdn.microsoft.com/en-us/library/8yttk7sy.aspx
For info about regex (in .NET context):
http://msdn.microsoft.com/en-us/library/hs600312.aspx

Hope that helps.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS