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

Posted on 2011-10-17
Medium Priority
Last Modified: 2012-05-12
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.
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 reader = input.OpenAsTextStream(1, 0)
Set regex = new RegExp

regex.Pattern = "^The name is"

While Not reader.AtEndOfStream
    line = reader.ReadLine()
    If Not regex.Test(line) Then
    End If


Open in new window


Author Comment

ID: 36980965
checking this...

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question