behdadsoft Posted October 23, 2014 Share Posted October 23, 2014 Hi. I wrote a script that can read a text file and write new text. now I want search in text content and find custom string then add "// " at first find string.Please Guide Me. Thanks #RequireAdmin #include <File.au3> ; Local Var Local $CreateList = @ScriptDir & "\List.txt" Local $ReadPath = @DesktopDir & "\Sample.txt" Local $Array = 0 Local $ReadList = _FileReadToArray ($ReadPath,$Array,0) _FileWriteFromArray ($CreateList,$Array,1) Link to comment Share on other sites More sharing options...
Danyfirex Posted October 23, 2014 Share Posted October 23, 2014 Could go through the array and compare if is true that you want use $array[index]=$array[index] & "" Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Solution kylomas Posted October 23, 2014 Solution Share Posted October 23, 2014 behdadsoft, Based on your definition the following should work without having to iterate an array... #RequireAdmin #include <File.au3> ; Local Var Local $CreateList = @ScriptDir & "\List.txt" Local $ReadPath = @DesktopDir & "\Sample.txt" local $The_String_To_Seacrh_For = 'some string' local $str = fileread($ReadPath) $str = stringreplace($str,$The_String_To_Seacrh_For,'//' & $The_String_To_Seacrh_For,1) ; replace first occurrence only filewrite($CreateList) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
behdadsoft Posted October 23, 2014 Author Share Posted October 23, 2014 Thanks kylomas Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now