Hello jindon,
Only try to split separated by commas, but without confusing the commas that are inside the fieds surrounded by double quotes.
The text doesn't compile since I showed as it is, to compile I need to write it inside the code like this:
Sub Split_Commas()
Dim MyText, m, x
MyText = """f oui, 2"",a,""f,2"",4,,5,,,,""k,4"",,g"
With CreateObject("VBScript.RegExp")
.Pattern = """[^""," & Chr(2) & "]+,[^""" & Chr(2) & "]"""
Do While .test(MyText)
Set m = .Execute(MyText)(0)
Mid$(MyText, m.firstindex + 1, m.Length) = Replace(m.Value, ",", Chr(2))
Loop
End With
x = Split(MyText, ",")
MsgBox Replace(Join(x, vbLf), Chr(2), ","), , UBound(x) + 1 & " elements"
End Sub
The first field is "f oui, 2" but is being splitted in 2 fields in the output.
Thanks for all the help.
Bookmarks