Jump to content
Sign in to follow this  
chirimbol

_ReplaceStringInFile question

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Might have looked at _StringBetween() as well.


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.

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...