Greetings! I am working on a vb.net application to extract and format text from a text file.
The basic goal: remove certain text and create 4 separate text files from the remaining file.
I've not gotten very far and am probably in over my head, but I'll post the little bit of code I do have.
I am willing to learn, but I will need help.
'remove 1st column and its trailing white space
Dim strCurrent As String = ""
Dim strRoot As String = ""
strCurrent = Directory.GetCurrentDirectory()
'strRoot = Directory.GetDirectoryRoot(strCurrent)
'strRoot = Directory.GetDirectoryRoot("\")
Catch E As Exception
'Console.WriteLine("Error determining root directory")
Dim strfileName As String
strfileName = strCurrent & "\" & "hotlist.txt"
Replace(strfileName, "\n1 ", "\n")
'GENERIC REGEX SEARCH & REPLACE. Use Regular Expressions to search/replace within file
Function Replace(ByRef file As String, ByRef searchFor As String, ByRef replaceWith As String) As Boolean
'function used during Validation
'use Regular Expressions to search for and replace user defined variables
Dim reader As New StreamReader(file) 'get a StreamReader for reading the file
Dim contents As String = reader.ReadToEnd() 'read the entire file at once
reader.Dispose() 'close up and dispose
'use regular expressions to search and replace text
contents = Regex.Replace(contents, searchFor, replaceWith, RegexOptions.IgnoreCase Or RegexOptions.Compiled)
Dim writer As New StreamWriter(file) 'get a StreamWriter for writing the new text to the file
writer.Write(contents) 'write the contents
writer.Dispose() 'close up and dispose
Return True 'return successful
Catch generatedExceptionName As Exception