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

Posted on 2011-10-17
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 74

    Accepted Solution

    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

    checking this...

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    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…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now