1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows C# Split String Not Working

Discussion in 'Software' started by Captain Xarzu, 18 Aug 2012.

  1. Captain Xarzu

    Captain Xarzu What's a Dremel?

    Joined:
    22 Aug 2007
    Posts:
    23
    Likes Received:
    1
    C# Split String Not 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?

    [​IMG]
     
  2. tehBoris

    tehBoris What's a Dremel?

    Joined:
    30 Jan 2011
    Posts:
    616
    Likes Received:
    25
    Are you sure they are proper tabs and not some thing else? What happens if you split on space?
     
  3. Highland3r

    Highland3r Minimodder

    Joined:
    25 Jul 2003
    Posts:
    7,559
    Likes Received:
    16
    Could try pulling the ASCII value of each char out of the string and checking that the delimiter is a tab.
    As a "workaround" you could split on whatever the ASCII value of the delimiter is instead of splitting on the tab char.
     
  4. CDomville

    CDomville ^ I am THIS Possum

    Joined:
    4 Jan 2011
    Posts:
    223
    Likes Received:
    10
    Is your backslash escaping correctly? (i.e. does \\t work instead?)
     
  5. theshadow2001

    theshadow2001 [DELETE] means [DELETE]

    Joined:
    3 May 2012
    Posts:
    5,284
    Likes Received:
    183
    I'm going to guess you need some kind of loop to deal with split method in order to enter each output to an array element.
     
  6. Captain Xarzu

    Captain Xarzu What's a Dremel?

    Joined:
    22 Aug 2007
    Posts:
    23
    Likes Received:
    1
    It turns out a text editor replaced the tabs with spaces without my approval or knowledge.
     
  7. vantonbill

    vantonbill What's a Dremel?

    Joined:
    25 Oct 2012
    Posts:
    1
    Likes Received:
    0

    try like this

    string arr[] = line.split('\\t');

    http://csharp.net-informations.com/string/csharp-string-split.htm

    vanton.
     
  8. Daedelus

    Daedelus What's a Dremel?

    Joined:
    7 May 2009
    Posts:
    253
    Likes Received:
    12
    what you have there should work. Are you 100% sure the string tab delimited?
     
  9. BentAnat

    BentAnat Software Dev

    Joined:
    26 Jun 2008
    Posts:
    7,230
    Likes Received:
    219
    text editors do that...
    Notepad++ helps find those relatively quickly, though.
     

Share This Page