Jump to content

remove word from text?


Recommended Posts

hello, I have a text and trying to erase the word "tree"

this word appears many times. I would remove it or replace it with a blank space.

i try this, but dont works:

WinWaitActive ("text.txt")

; Here i open the text

$sExtract = StringRegExpReplace ("tree", " ", " ")

ClipPut($sExtract)

Link to comment
Share on other sites

Hi,

if i understand what you want:

1) You have text.txt

2) you want to replace 'tree' with a blank

2 possibilities:

1) String manipulation, leaving text.txt as it was:

$string = FileRead (@ScriptDir & "\text.txt") ; text.txt is in same folder as your script
$string = StringReplace ($string, "tree", " ")
ClipPut ($string)

2) Change 'tree' straight in text.txt

#include <file.au3>
_ReplaceStringInFile (@ScriptDir & "\text.txt", "tree", " ")
ClipPut (FileRead (@ScriptDir & "\text.txt"))

;-))

Stefan

Link to comment
Share on other sites

Hi,

you are using File command to read out text from a window -> never works.

See helpfile for further information:

ControlGetText ()

Use example script to see whats going on.

If you don't use notepad, use AutoIt v3 Window Info to get the class of your window.

If you have the class information, you can read the text into variable.

Then you can start string manipulation.

;-))

Stefan

Edited by 99ojo
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...