如何在vb.net中分割字符串 [英] how to split a string in vb.net
本文介绍了如何在vb.net中分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想知道如何在两个单词之间拆分字符串,即字符串是否为
亲爱的朋友,你好吗"
我喜欢分裂
你好,你好"
可以定义两个单词之间的分割函数....
在此先感谢
seshu
hi all,
I like to know how to split a sting between two words i.e, if the string is
"HELLO MY DEAR FRIEND HOW ARE YOU"
i like to split
"HELLO HOW ARE YOU"
is possible to define the split function between two words....
Thanks in advance
seshu
推荐答案
您的问题有些令人困惑.
Split
方法返回字符串数组.例子
Your question is somewhat confusing.
Split
method returns array of string. Example
Dim words As String() = "HELLO MY DEAR FRIEND HOW ARE YOU".Split(New Char() {" "c})
将返回
数组
HELLO
我
亲爱的
朋友
如何
ARE
你.
可以使用String
类的Substring
方法来实现您好".
或者,您也可以使用改进问题"小部件来解释您的问题.
will return array of
HELLO
MY
DEAR
FRIEND
HOW
ARE
YOU.
"HELLO HOW ARE YOU" this can be achieve using Substring
method of String
class.
Or you can explain your question by using Improve Question widget.
您可以使用String.Split()
方法拆分字符串,这将返回一个单词数组.
根据您的要求,您需要使用"( space )分割字符串.将返回一个包含单词的数组.现在使用loop并根据需要创建字符串.
you can split your string withString.Split()
method, which will return you a array of words.
with your requirement, u need to split the string with " "(space). will return you a array with words. now use loop and make string whatever you want.
对于更复杂的secnarios,我们可以使用正则表达式来拆分字符串.但是,在这里,split
是最好的解决方案.
For more complex secnarios we could use a regular expression to split a string. However here, split
is the best solution.
这篇关于如何在vb.net中分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文