Jump to content

How to delete a character from a .txt file


Recommended Posts

  • Moderators

Hi,

I would like to know how can I delete a character from a text file using FileWrite.

Do I need to FileWrite the backspace character ? If yes then how ?

Thank You

Look closely
#include <file.au3>
Local $Path2File = 'Path2File'
Local $nArray = ''
Local $NEW_FILE = @DesktopDir & '\NEW_TXT.TXT'
_FileReadToArray($Path2File, $nArray)
For $i = 1 To UBound($nArray) - 1
    If StringInStr($nArray[$i], 'StringINeed2Find') Then
        $blah = $blah & StringReplace($nArray[$i], 'ChangeThis', '') & Chr(01)
        FileWriteLine($NEW_FILE, $blah)
    Else
        $blah = $blah & Chr(01)
        FileWriteLine($NEW_FILE, $blah)
    EndIf
Next
$blah = StringSplit(StringTrimRight($blah, 1), Chr(01))
For $x = 1 To UBound($blah) - 1
    FileWriteLine($NEW_FILE, $blah[$x])
Next

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Your quite welcome... You might also want to take a close look at StringRegExpReplace()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
 Share

  • Recently Browsing   0 members

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