如何用空格分割String。 [英] How to split the String with space.?
问题描述
您好,
我想用空格分割字符串。
Ex。青少年,儿童,婴儿,青少年,男性,女性
字符串就像是明智的,如果我写Youth Baby Young Adult,我想在此分裂字符串方式。
青少年
宝贝
年轻成人
是否有人有这个字符串的解决方案......?
你可以使用String.Split。但是,如果Young Adult
是单个值,则无法正确检测到该值,因为每个空格都是分隔符。结果将是:
青少年
宝贝
年轻
成人
http://msdn.microsoft.com /en-us/library/b873y76a%28v=vs.110%29.aspx [ ^ ]
祝你好运!
>
引用:如果我写青少年宝贝青少年,字符串就像是明智的,我想以这种方式分割字符串。
青少年
宝贝
青少年
这是一项相当复杂的任务。在最简单的形式中,你必须为以下语法构建一个解析器:
statments:= statement [''statement]
statement:= [形容词] noun
和能够为标识符<$ c生成令牌名词
的词法分析器$ c>'Youth','Baby','Adult'以及令牌形容词
标识符'Young'
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...?
you could use String.Split. But ifYoung 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!
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 tokennoun
for the identifiers'Youth', 'Baby', 'Adult'
and the tokenadjective
for the identifier'Young'
.
这篇关于如何用空格分割String。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!