vbs replace text

Hello Experts,
Once again I ask for help. Not even sure this is possible. The following script works OK and all instances of "LDEBIT" are replaced. However, I would like to replace all instances of "^" or CHR(94). I have tried both those and it doesn't work.

Dim pattern
Dim replacement
' We must define ForWriting because the
' imode constants are unknown to VBScript
Const ForWriting = 2
Const inF = "NewSavings.qif"
Const outF = "Testfile1.txt"

' Here are the strings for replacement.
pattern = "LDEBIT"
replacement = vbCRLF

Dim Text
Dim fso                 ' Object variable
Dim oFileIn, oFileOut   ' Text stream
Dim path, fileIn, fileOut

path = GetPath()        ' Retrieve current path to script.
fileIn = path & inF     ' Create filenames.
fileOut = path & outF

Set fso = CreateObject("Scripting.FileSystemObject")

If Not fso.FileExists(fileIn) Then  ' Input file exists?
    WScript.Echo "File '" & fileIn & "' not found"
    WScript.Quit 1
End If

' Input file present; open file and create output file.
Set oFileIn = fso.OpenTextFile(fileIn)   ' Open input file.
Set oFileOut = fso.OpenTextFile(fileOut, _
                    ForWriting, True)    ' Open output file.

Do While Not (oFileIn.atEndOfStream)
    Text = oFileIn.ReadLine              ' Read a line.
    Text = Filter(Text, pattern, replacement)
    oFileOut.WriteLine Text              ' Write text.
Loop

WScript.Echo "Text file: " & fileIn & vbCrLf & _
             "Written into: " & fileOut

Function GetPath
    ' Retrieve the script path.
    Dim path
    path = WScript.ScriptFullName  ' Script name
    GetPath = Left(path, InStrRev(path, "\"))
End Function

Function Filter(txt, expr1, expr2)
    ' Replace expr1 with expr2 in text.
    Dim oReg

    Set oReg = New RegExp        ' Create regular expression.
    oReg.Global = True           ' All matches
    oReg.IgnoreCase = True       ' Make case-insensitive.

    ' Replace all expr1 with expr2.
    oReg.Pattern = expr1          ' Set pattern.
    Filter = oReg.Replace(txt, expr2)
End Function

'*** End
bravotangoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

R_RajeshCommented:
Hi bravotango, try this:

pattern = "\^"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bravotangoAuthor Commented:
Hi R Rajesh. That works nicely many thanks. You have a good day too!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.