VB.NET String.Split Method?

I'm having problems using the String.Split method. An example is here:

Dim tstString As String = "something here -:- URLhere" Dim newtstString = tstString.Split(" -:- ") MessageBox.Show(newtstString(0)) MessageBox.Show(newtstString(1)) 

The above in PHP (my native language!) Will return something here AND the URL in the posts.

In VB.NET, I get:

 something here 

and

 : (colon) 

Is String.Split used only with standard characters? I can't seem to figure it out. I am sure it is very simple!

+8
split regex
source share
1 answer

This is what you need to do to prevent the string from being converted to a Char array.

  Dim text As String = "something here -:- urlhere" Dim parts As String() = text.Split(New String() {" -:- "}, StringSplitOptions.None) 

This is a member function of System.String that you should use in this case

 Public Function Split(ByVal separator As String(), ByVal options As StringSplitOptions) As String() 
+16
source share

All Articles