Jump to content

_ReplaceStringInFile question


 Share

Recommended Posts

Hi,

I'm using _ReplaceStringInFile function and I cannot do all I would want to do.

In fact I have a text file like this

"texttexttexttexttexttexttexttext

texttexttexttext

.

.

OK

text

texttexttext

text

OK

.

.

.

texttexttexttexttexttexttexttext"

And I just want to have the text between the 2 OK on my output file.

With the _ReplaceStringInFile function I had no problem to find and replace the OK.

My idea was to replace "*OK" by "OK" and then "OK*" by "OK" ....

But I don´t know how I have to do with AutoIt. Maybe there is an easier way?

Thanks in advance for your help.

Link to comment
Share on other sites

  • Developers

Something like:

$Data = FileRead("text.txt")
$data = StringTrimLeft($data,StringInStr($data,"ok")+2)
$data = StringLeft($data,StringInStr($data,"ok")-1)
FileWrite("output.txt",$data)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...