Arrays 从字符串VB.NET中提取多个值
我正在处理http URL,所有URL都是正确的,但有些URL如下: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”(使用普通字符串连接) 实施这些步骤应该很容易,并
基本上这是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