vb.net:您可以通过将字符串分割字符串 [英] vb.net: can you split a string by a string

查看:1254
本文介绍了vb.net:您可以通过将字符串分割字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我可以做到这一点:

 拆分= temp_string.Split(<记录&GT的开始;)
 

那些你们推荐:

 拆分= Regex.Split(temp_string,<记录&GT的开始;)
 

它不工作。它只是返回的第一个字符<

和那些你推荐:

 昏暗myDelims作为字符串()=新的String(){<记录&GT的开始;}
拆分= temp_string.Split(myDelims,StringSplitOptions.None)
 

这是不工作要么。它也只返回的第一个字符

解决方案

试试这个:

 的String [] myDelims =新的String [] {<记录&GT的开始; };
拆分= temp_string.Split(myDelims,StringSplitOptions.None);
 

通过$ C $ D转换器的结果在这个运行此

 昏暗myDelims作为字符串()=新的String(){<记录&GT的开始; }
拆分= temp_string.Split(myDelims,StringSplitOptions.None)
 

您可能还需要躲避人字形,像这样的:

 \<记录\&GT开始;
 

for example, can i do this:

split = temp_string.Split("<beginning of record>")

those of you recommended:

split = Regex.Split(temp_string, "< beginning of record >")

its not working. its just returning the first char "<"

and those of you that recommended:

Dim myDelims As String() = New String(){"< beginning of record >"}
split = temp_string.Split(myDelims, StringSplitOptions.None)

this is not working either. it's also returning just the first char

解决方案

Try this:

string[] myDelims = new string[] { "<beginning of record>" };
split = temp_string.Split(myDelims,StringSplitOptions.None);

Running this through a code converter results in this:

Dim myDelims As String() = New String() { "<beginning of record>" }
split = temp_string.Split(myDelims, StringSplitOptions.None)

You may also need to escape the chevrons, like this:

"\< beginning of record \>"

这篇关于vb.net:您可以通过将字符串分割字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆