Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[SOLVED] Split String

string

  • This topic is locked This topic is locked
4 replies to this topic

#1 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 28 July 2012 - 11:42 AM

Let's use this string for example:

String name = "   Joseph Karolin";

As you can see it has 3 spaces before first letter. I want to separate Karolin from other part of string and keep it. Other part of string I want to delete.
This is stupid thing but I don't know how to do it.
Some help?

This post has been promoted to an article
  • 0

Microsoft Student Partner, Microsoft Certified Professional


#2 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 28 July 2012 - 12:27 PM

This also can be marked as Solved.
  • 0

Microsoft Student Partner, Microsoft Certified Professional


#3 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 28 July 2012 - 12:45 PM

What were your solution?
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#4 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 28 July 2012 - 12:57 PM

Oh forgive me, I forgot to provide that solution here.
I have tried with using only one whitespace separator even I was afraid how will look that because there was 3 whitespaces at the begin of string.
So I have used this:
pamti = input212.InnerText;
char[] seps = {' '};
string[] krediti = pamti.Split(seps);
int krediti2 = Convert.ToInt16(krediti[5]);
label5.Text = Convert.ToString(krediti2);

  • 0

Microsoft Student Partner, Microsoft Certified Professional


#5 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 28 July 2012 - 02:13 PM

This topic has been marked as SOLVED. If you have a similar question or topic, go back to the subforum and start a new topic to continue discussions.
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download