Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Foley67 · Apr 17, 2013 at 06:47 PM · c#stringstring.split

String.Split Not Splitting Correctly. Some Duplicates are being deleted.

So i've been trying to solve this for hours with no avail. I try to split this string here (AllPanelData), splitting at the "/"...:
5
/0
/0
/0.82
/0
/0
/-0.82
/-0.5
/0.3
/0
/0.2
/0.2
/0.2
/0.4
/0.4
/0.4

into an array and then display it in the debug window using this:

 AllPanelData = feedText.Split("/" [0]);
     for (int i=0; i<AllPanelData.Length; i++)
         {
             Debug.Log (AllPanelData[i]);
                 }
 

However the debug window shows that the values of AllPanelData are:
5
0
0.82
0
-0.82
0.5
0.3
0.2
0.4
0.4
0.4

So it seems like half the characters have disappeared. This seems to happen with 0's or duplicates (e.g. when 0.2 appears twice in the text but only set to one member of the array)

Any solution would be great.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Dracorat · Apr 17, 2013 at 06:52 PM

I can't reproduce that with your code.

Code I used (I just created a Console App since this is straight string manipulation);

 string feedText = @"5
 /0
 /0
 /0.82
 /0
 /0
 /-0.82
 /-0.5
 /0.3
 /0
 /0.2
 /0.2
 /0.2
 /0.4
 /0.4
 /0.4
 ";
 string[] AllPanelData = feedText.Replace("\r", "").Replace("\n", "").Split('/');
 for (int i=0; i < AllPanelData.Length; i++)
 {
     Console.WriteLine(AllPanelData[i]);
 }

Output:

 5  
 0  
 0  
 0.82  
 0  
 0  
 -0.82  
 -0.5  
 0.3  
 0  
 0.2  
 0.2  
 0.2  
 0.4  
 0.4  
 0.4  

Edit: Now that I think about it, I think Debug.Log sometimes hides duplicate values.

Go to the Console window and unclick collapse.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Foley67 · Apr 17, 2013 at 07:44 PM 0
Share

Wow, incredibly it was that the console window had collapse checked .Everything is working fine now and i've accomplished more since fixing that than I have the rest of the entire day. Thanks!

avatar image Dracorat · Apr 17, 2013 at 08:03 PM 0
Share

$$anonymous$$ake sure to accept the answer then. Glad you're on your way!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

How to extract part of a string variable? 1 Answer

Distribute terrain in zones 3 Answers

C# String Array Has Missing or Incorrect Keycode Strings 2 Answers

Can I create a list with an int/float and a string? C# 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges