aString.Split question

skokkinos

New member
Joined
Mar 7, 2008
Messages
2
Programming Experience
Beginner
Hi everybody,
I' m trying to parse an .m3u playlist file and I need to split a string (the whole m3u data actually) not in a single char or array of chars but a whole string instead.
For example I'd like to use:
VB.NET:
Dim theM3U As String
theM3U = My.Computer.FileSystem.ReadAllText(System.Environment.CurrentDirectory & "\test01.m3u")

Dim theM3Uarray() As String
theM3Uarray = theM3U.Split("#EXT")

Unfortunately by using the previous block of code I get an array of strings split at only the "#" while I'd like the whole "#EXT" to be used as delimiter for the split.

Any info would be much appreciated.
Thanks in advance..


PS: I'm a newbie in VB .NET so please excuse my lack of knowledge.
 
Edit:

I just looked at the documentation for the Split() method and found that it will allow you to split using a string, but you are only providing the parameters for it to be splitting on a character. Try:

VB.NET:
dim splitters() as string= {"#EXT"}
theM3U.Split(splitters, system.StringSplitOptions.RemoveEmptyEntries)
 
Last edited:
Another alternative would be to split on the line break (Environment.NewLine character) and proceed knowing that every two lines go together.
 
Back
Top