Question : VBA Splitting a line with a comma seperator and quote qualifer

Hi,
im playing with this and cant work out how to change it so that the rather then using a single quote ('), i use a double quote (")

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 single quote qualifer

arrTest = SplitAdv(TestString)

For x = 0 To UBound(arrTest)
   MsgBox arrTest(x)
Next
End Sub


obviously i could do a simple replace(TestString,"""","'")
however i would rather update the function if possible?

nb. this is in excel 2003 vba

Answer : VBA Splitting a line with a comma seperator and quote qualifer

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
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
Random Solutions  
 
programming4us programming4us