Function SplitAdv(strInput)
'http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21935286.html
Dim objRE
Set objRE = CreateObject("VBScript.RegExp")
objRE.IgnoreCase = True
objRE.Global = True
objRE.Pattern = ",(?=([^""]*""[^""]*"")*(?![^""]*""))" ' uses a " qualifer
SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b")
End Function
Sub testingsplit()
Dim TestString, arrTest, x
'TestString = "123, 'Bill', 'is rocking', 'what, ok you are right'" 'user a single quote qualifer
'this needs to work:
TestString = "123, ""Bill"", ""is rocking"", ""what, ok you are right""" 'user a double quote qualifer
arrTest = SplitAdv(TestString)
For x = 0 To UBound(arrTest)
MsgBox arrTest(x)
Next
End Sub
|