Jump to content

_FileReadToArray and then "Find and Replace text" ?


archies
 Share

Recommended Posts

Hey guys,

Say I have this test.txt file:

The dog catcher chased the dog down the street.
The dog chased the cat down the street.
The cat chased the mouse down the street.
The mouse got away from the cat.
The cat got away from the dog.
The dog got away from the dog catcher

Ok now I want to read this file into an array so:

#include <File.au3>
Dim $MyArray
_FileReadToArray(c:\test.txt, $MyArray)

I'm not sure what the "Dim" thing is for but I've seen it used when someone else helped me the other day with another problem so I'm assuming it is needed.

Anyways, now I want to perform a couple of operations on "$MyArray" and one of them is to do some basic "find and replace" text.

So for this example, I want to replace the word "street" with the word "road" in the whole "$MyArray". And also the word "got" with the word "ran".

So if I were to do a _FileWriteFromArray at this point, I would get a txt file that looks like this:

The dog catcher chased the dog down the road.
The dog chased the cat down the road.
The cat chased the mouse down the road.
The mouse ran away from the cat.
The cat ran away from the dog.
The dog ran away from the dog catcher

Hope it's all clear.

Thanks for the help guys!

PS: I tried to do StringReplace($MyArray,street,road) but it seems to have no affect :P

Edited by archies
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...