Sign in to follow this  
Followers 0
chirimbol

_ReplaceStringInFile question

5 posts in this topic

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



StringInStr

StringTrimLeft

StringInStr

StringTrimRight

These function should get you started


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

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)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        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  
Followers 0