Chr*_*ris 8 .net regex vb.net split
我在使用String.Split方法时遇到了一些问题,例如:
Dim tstString As String = "something here -:- URLhere"
Dim newtstString = tstString.Split(" -:- ")
MessageBox.Show(newtstString(0))
MessageBox.Show(newtstString(1))
Run Code Online (Sandbox Code Playgroud)
上面用PHP(我的母语!)会在这里返回一些内容并在消息框中返回URL.
在VB.NET中,我得到:
something here
Run Code Online (Sandbox Code Playgroud)
和
: (colon)
Run Code Online (Sandbox Code Playgroud)
String.Split仅适用于标准字符吗?我似乎无法想出这个.我确定这很简单!
ja7*_*a72 16
这是您需要做的,以防止字符串转换为Char数组.
Dim text As String = "something here -:- urlhere"
Dim parts As String() = text.Split(New String() {" -:- "}, StringSplitOptions.None)
Run Code Online (Sandbox Code Playgroud)
这是System.String您在这种情况下需要使用的成员函数
Public Function Split(ByVal separator As String(), ByVal options As StringSplitOptions) As String()
Run Code Online (Sandbox Code Playgroud)