plzhelp Posted June 23, 2011 Posted June 23, 2011 Hello. I've got a problem with String Replace, I mean, I have for example that text: blablabla blablabla delete everything after this on this line blablabla2 blablabla I don't know how to do that, that I get: blablabla blablabla blablabla Sorry for my bad english.
sleepydvdr Posted June 23, 2011 Posted June 23, 2011 _FileWriteToLine($file, 2, "blablabla", 1) #include <ByteMe.au3>
plzhelp Posted June 23, 2011 Author Posted June 23, 2011 I mean, I don't know which line I wanna change, it has to search the line where's 'delete everything after this line' and delete everything after this text. $infile = "test.txt" $data = FileRead ($infile) $new_data3 = StringReplace ($data, @CRLF, '') $hFile = FileOpen ($outfile, 2) FileWrite ($hFile, $new_data3) FileClose ($hFile) and how to add in that, what i've said
sleepydvdr Posted June 23, 2011 Posted June 23, 2011 #include <string.au3> #include <file.au3> $i = 1 $j = _FileCountLines("test.txt") do $line = FileReadLine("test.txt", $i) If NOT StringInStr($line, "some text to look for") Then FileWrite("output.txt", $line & @CRLF) Else ExitLoop EndIf $i += 1 Until $i = $j #include <ByteMe.au3>
plzhelp Posted June 23, 2011 Author Posted June 23, 2011 Hmm sleepydvdr idk, but it deletes full line, for example : blablabla bla bla bla bla some text to look for bla bla bla bla bla And the output: blablabla bla ;/ Is that possible to do ?
sleepydvdr Posted June 23, 2011 Posted June 23, 2011 $i = 1 $j = _FileCountLines("test.txt") do $line = FileReadLine("test.txt", $i) If NOT StringInStr($line, "some text to look for") Then FileWrite("output.txt", $line & @CRLF) Else $lastline = StringSplit($line, "some text to look for", 1) FileWrite("output.txt", $lastline[1]) Exit EndIf $i += 1 Until $i = $j #include <ByteMe.au3>
somdcomputerguy Posted June 23, 2011 Posted June 23, 2011 Here's a different way: #include <file.au3> #include <array.au3> Local $aFile, $iline _FileReadToArray("test.txt", $aFile) $iline = _ArraySearch($aFile, "delete everything", 1, $aFile[0], 0, 1, 0) _FileWriteFromArray("test.txt", $aFile, 1, $iline) test.txt - before Line 1 Line 2 delete everything after this on this line blablabla2 Line 3 test.txt - after Line 1 Line 2 delete everything after this on this line blablabla2 - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now