Solved

# Need a vbscript to delete a  line in log file starting with specific string

Posted on 2011-10-17
Medium Priority
231 Views
I need to delete the lines in log that start with a string for example"
The name is
The value is 1234
The name is Tony White

After deletion the log will have

The value is 1234
and the line with name will be gone.
0
Question by:newone2011

LVL 75

Accepted Solution

käµfm³d   👽 earned 2000 total points
ID: 36980601
Try this:

Set fso = CreateObject("Scripting.FileSystemObject")
Set input = fso.GetFile("C:\path\to\file.txt")
Set output = fso.CreateTextFile("C:\path\to\output.txt", True)
Set regex = new RegExp

regex.Pattern = "^The name is"

If Not regex.Test(line) Then
output.WriteLine(line)
End If
Wend

output.Close

0

Author Comment

ID: 36980965
checking this...
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
###### Suggested Courses
Course of the Month16 days, 1 hour left to enroll