Jump to content

Removing a line in a file

Recommended Posts


I am trying to find a specific (varying) line in a text file and delete it. Here I found a script that deletes blank lines which I thought would be easy to adapt for that purpose. But I am struggling with special characters; the line I want to delete looks like this:

user_pref("sessionsaver.static.default.session0", "session0  1127  844  -4  -4  111111  0  1   z1 |0 |0,0| http://www.heise.de/newsticker  1");

So I thought I test for StringLeft($line, 48) which is the static part of the line.

But AutoIt gives me errors ("could not parse") even when doubling the double quotes as mentioned in the FAQ.

How can I handle this string?

Link to comment
Share on other sites

maybe this would help ( not sure exactly what you want )

#include <GUIConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <String.au3>

Dim $result_3 = ""

$test = "xxwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxhttp://my-domain.comxxxxxssssssssssssssssssssssxx"

$L_loc = StringInStr($test, "http")

$result = StringTrimLeft( $test, $L_loc -1)

$R_loc = StringInStr($result, ".com", 0, -1)

$result_2 = StringLeft( $result, $R_loc +3)

If $result_2 <> $result_3 Then
    $result_3 = $result_2
;write the line to the file
    MsgBox(0,"test", "final result = " & $result_3)

Hope it helps



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...