I tested the solution in #4 by AI on this string:
123,, "John,", Smith,,,
I expected/wanted to get (-=empty):
123
-
John,
Smith
-
-
-
But John, was in quotes, and the last three empty items were dropped.
I wrote my own version without Regex. It gave the right answer and turned out to be about four times faster: 15msec/10000 iterations vs 68msec /10000 iterations.
Private Sub parseString(s As String) As List
Dim aList As List: aList.Initialize
Dim sb As StringBuilder: sb.Initialize
Dim inQUOTE As Boolean
For i = 0 To s.Length - 1
Dim c As String = s.CharAt(i)
If c = QUOTE Then
If inQUOTE Then inQUOTE = False Else inQUOTE = True
Else If c = "," And Not(inQUOTE) Then
aList.Add(sb.toString.Trim)
sb.Initialize
Else
sb.Append(c)
End If
Next
aList.Add(sb.toString.Trim)
Return aList
End Sub