Hello again, I am trying to replace a string which is actually different from line to line in a text file. I want to end up with a filename but without the path. For example:
My text file contains:
C:\test\testingmore\filename.mpg
C:\test\testfiles1\testfile4.mpg
W:\testinglocation\testingmore\testfiles9.mpg
I would like to replace the path in each line with nothing so it reads as follows:
filename.mpg
testfile4.mpg
testfiles9.mpg
I have the following code written but I have something wrong as I get the error below:
parsing "*\" - Quantifier {x,y} following nothing.
Imports System.Text
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fso1, inputFile1, outputFile1
Dim str0 As String
Dim str10 As String
Dim str20 As String
Dim str30 As String
fso1 = CreateObject("Scripting.FileSystemObject")
inputFile1 = fso1.OpenTextFile("c:\WDrive.txt", 1)
str0 = inputFile1.ReadAll
str10 = System.Text.RegularExpressions.Regex.Replace(str0, "*\", "")
str20 = str10.Replace(".mpg", "")
str30 = str20.Replace(".ts", "")
inputFile1.close()
outputFile1 = fso1.CreateTextFile("c:\WDriveReplaced.txt", True)
outputFile1.Write(str30)
outputFile1.close()
End Sub
End Class