Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 从字符串VB.NET中提取多个值_Arrays_Vb.net - Fatal编程技术网

Arrays 从字符串VB.NET中提取多个值

Arrays 从字符串VB.NET中提取多个值,arrays,vb.net,Arrays,Vb.net,我正在处理http URL,所有URL都是正确的,但有些URL如下: 基本上这是3个URL。我需要把他们分开。但这不是唯一的问题,我需要使用“IF”语句来确认是否存在包含多个“http://”的字符串,因为其他URL是正确的您可以使用以下算法: 检查字符串是否包含“%20http”(使用string.contains) 如果是,则在“%20http”处拆分(使用String.split) 在除第一个字符串外的每个拆分字符串处添加“http”(使用普通字符串连接) 实施这些步骤应该很容易,并

我正在处理http URL,所有URL都是正确的,但有些URL如下:


基本上这是3个URL。我需要把他们分开。但这不是唯一的问题,我需要使用“IF”语句来确认是否存在包含多个“http://”的字符串,因为其他URL是正确的

您可以使用以下算法:

  • 检查字符串是否包含“%20http”(使用
    string.contains
  • 如果是,则在“%20http”处拆分(使用
    String.split
  • 在除第一个字符串外的每个拆分字符串处添加“http”(使用普通字符串连接)
实施这些步骤应该很容易,并且(有意地)留给读者作为练习。事实上,在正确实现它们之后,您可能会意识到可以完全跳过第一步。

尝试以下方法:

Dim strURLToEvaluate As String = "http://site.com/abgAz1nBs.jpg%20http://site.com/adtEh96Wj.jpg%20http://site.com/acum1N6qN.jpg"

Dim strURLs As String() = Strings.Split(strURLToEvaluate, "%20http://")

If strURLs.Length > 1 Then MsgBox("More than one URL!")

For Each strURL In strURLs
    If Strings.Left(strURL, Len("http://")) <> "http://" Then strURL = "http://" & strURL
    MsgBox(strURL)
Next strURL
Dim strURLToEvaluate As String=”http://site.com/abgAz1nBs.jpg%20http://site.com/adtEh96Wj.jpg%20http://site.com/acum1N6qN.jpg"
Dim strURLs As String()=Strings.Split(strURLToEvaluate,“%20http://”)
如果strURLs.Length>1,则MsgBox(“多个URL!”)
对于strURLs中的每个strURL
如果Strings.Left(strURL,Len(“http://”)为http://”,则strURL=“http://”为&strURL
MsgBox(strURL)
下一个strURL