Results 1 to 5 of 5

Thread: Split question

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    3

    Split question

    I'd like to know how can I split a string with tabs as delimiters

    I tried the following code

    string inputString = "0\t100\t-5\t300\t500"; \\ \t are tabs
    string delimStr ="\t";
    char [] delimiter = delimStr.ToCharArray();
    string [] split = input.Split(delimiter, x);

    at this point, I expected the split array to contain the numbers separately (0, 100, -5, 300, and 500)

    but instead the array only contains one element that is 0\t100\t-5\t300\t500

    Any tips on this?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Split question

    Try it with \\t.

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    3

    Re: Split question

    Hmm it's still not working

    Am I missing something here?

    Code:
    string delimStr ="\\t";
    I debug, therefore I am

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: Split question

    this works for me
    Code:
    string inputString = "0\t100\t-5\t300\t500"; 
    char delimStr ='\t';
    string[] split = inputString.Split(delimStr);

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    3

    Re: Split question


    It works


    Thank you so much!!
    I debug, therefore I am

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width