Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want to split the string with space.
For Ex. Youth, Child, Baby, Young Adult, Male, Female

String is like wise if suppose I Write "Youth Baby Young Adult", I want to split string in this manner.
Youth
Baby
Young Adult

Is any one have solution for this string...?
Posted

you could use String.Split. But if Young Adult is a single value it is not possible to detect that properly because every space would be a separator. The result would be:
Youth
Baby
Young
Adult

http://msdn.microsoft.com/en-us/library/b873y76a%28v=vs.110%29.aspx[^]

Good luck!
 
Share this answer
 
Comments
Niravvasoya 11-Sep-14 10:41am    
Ya Young Adult is one word, So I need to find the logic for this.
Sergey Alexandrovich Kryukov 11-Sep-14 11:00am    
There is no logic, unless you do detailed semantic analysis. And even if your do, there can be many ambiguities. You rather need to review the whole approach, whatever it is.
—SA
Sergey Alexandrovich Kryukov 11-Sep-14 11:01am    
5ed. Please see my other comment.
—SA
Quote:
String is like wise if suppose I Write "Youth Baby Young Adult", I want to split string in this manner.
Youth
Baby
Young Adult

This is a pretty complex task. In its simplest form you have to build a parser for the following grammar:
statments := statement [' ' statement ]
statement := [ adjective ] noun 


and a lexer able to produce the token noun for the identifiers 'Youth', 'Baby', 'Adult' and the token adjective for the identifier 'Young'.
 
Share this answer
 
Comments
Matt T Heffron 11-Sep-14 12:01pm    
+5!
CPallini 11-Sep-14 12:10pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900