Imports System
Imports System.Text.RegularExpressions
Public Class Test
Public Shared Sub Main()
Dim input As String = "ASD~QW~DFGH~LOP~GGGH~123~SXC~QL~"
Print(Split("asd"))
Print(Split("asd~"))
Print(Split("ASD~QW~DFGH~LOP~GGGH~123~SXC~QL~"))
Print(Split("ASD~QW~DFGH~LOP~GGGH~123~SXC~QL~jones"))
Console.WriteLine("....bye")
End Sub
Public Shared Sub Print(words As List(Of String))
Console.WriteLine("Found {0} words", words.Count)
For Each Val As String In words
Console.Write(" [{0}]", Val)
Next
Console.WriteLine()
End Sub
Public Shared Function Split(input As String) As List(Of String)
Dim results = New List(Of String)
Dim pattern As String = ".*?~([^~]+?)(?=~)"
Dim re As Regex = New Regex(pattern)
For Each mtch As Match In re.Matches(input)
results.Add(mtch.Groups(1).Captures(0).Value)
Next
Return results
End Function
End Class
Visual Basic.Net Compiler version 0.0.0.5914 (Mono 2.4.2 - r)
Copyright (C) 2004-2008 Rolf Bjarne Kvinge. All rights reserved.
/home/R42Oeh/prog.vb (15,54) : Error VBNC30451: Could not resolve the name 'List'
There were 1 errors and 0 warnings.
Compilation took 00:00:00.7200100