I am trying to use a regex pattern to remove an unwanted " from a csv file. When I run the script the compiler says that there is a problem with the declaring of the regex pattern.
it seems to break at regEx.Pattern = "("[^,"]+)"([^,"]+")" when complied. How do you set the reference of the patttern to the variable?
("[^,"]+)"([^,"]+") This is the regex pattern I am using with "$1$2" for the replace.
This is running on a XP environment.
Here is an example of the code I am working with:
Option Explicit
Dim regEx,newstr3, mypat
Dim fPOSIn
Dim fPOSOut
Dim cArray
Dim fso, inF, outF, sLine
dim mylen,sLine2
Set fso = CreateObject("Scripting.FileSystemObject")
Set inF = fso.OpenTextFile(fPOSIn, 1)
fPOSIn = "D:\Webinv\POSFile\PosDropOff\POSTEMP\Barneys_858_O_20081105.csv"
Do Until inF.AtEndOfStream
sLine = inF.ReadLine
sLine2 = sLine
Set regEx = CreateObject("vbscript.regexp")
regEx.Pattern = "("[^,"]+)"([^,"]+")"
regEx.IgnoreCase = True
regEx.Global = True
Line2 = regEx.Replace("("[^,"]+)"([^,"]+")", "$1$2")
loop
set inF = nothing
set outF = nothing
Set fso = nothing
Freddy