tempman Posted March 27, 2014 Share Posted March 27, 2014 ;map.txt ;| IP | Status | ;---------------------------- ;| 10.27.52.5 | disabled | ;| 10.27.52.6 | disabled | #include <array.au3> #include <File.au3> $dump = "map.txt" Local $String _FileReadToArray($dump, $String) _arraydisplay($String) For $i = 1 To UBound($String) - 1 $answer = StringRegExp($String[$i],'((?:\d{1,3}\.){3}\d{1,3})',3) _arraydisplay($answer) Next How to save $answer to ip.txt? Link to comment Share on other sites More sharing options...
Palestinian Posted March 27, 2014 Share Posted March 27, 2014 FileWrite maybe? Link to comment Share on other sites More sharing options...
tempman Posted March 27, 2014 Author Share Posted March 27, 2014 Try it! Link to comment Share on other sites More sharing options...
Palestinian Posted March 27, 2014 Share Posted March 27, 2014 (edited) Try this one. #include <array.au3> #include <File.au3> $dump = "d:\map.txt" $oIP = "d:\ip.txt" Local $String _FileReadToArray($dump, $String) _ArrayDisplay($String) For $i = 1 To UBound($String) - 1 $answer = StringRegExp($String[$i], '((?:\d{1,3}\.){3}\d{1,3})', 3) _ArrayDisplay($answer) $oString = _ArrayToString($answer) FileWrite($oIP, $oString & @CRLF) Next Edited March 27, 2014 by Palestinian Link to comment Share on other sites More sharing options...
tempman Posted March 27, 2014 Author Share Posted March 27, 2014 Did you even try the code you wrote?!? Link to comment Share on other sites More sharing options...
Palestinian Posted March 27, 2014 Share Posted March 27, 2014 Did you even try the code you wrote?!? I did, and this is what I got inside the ip.txt file after running it: 10.27.52.5 10.27.52.6 If that's not what you are looking for then please try to explain your question better. Link to comment Share on other sites More sharing options...
Solution Malkey Posted March 27, 2014 Solution Share Posted March 27, 2014 An example. #include <array.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ;----- Create map.txt file ----------------- Local $dump = "map.txt" If FileExists($dump) = 0 Then FileWrite($dump, "| IP | Status |" & @CRLF & _ "----------------------------" & @CRLF & _ "| 10.27.52.5 | disabled |" & @CRLF & _ "| 10.27.52.6 | disabled |") ;ConsoleWrite(FileRead($dump) & @LF) ;-----> End of create "map.txt" file ----------------- Local $answer = StringRegExp(FileRead($dump), '((?:\d{1,3}\.){3}\d{1,3})', 3) _ArrayDisplay($answer) Local $SaveTo = "ip.txt" _FileWriteFromArray($SaveTo, $answer) ; ----- View "ip.txt" file and optional clean up files from disk ------------ Local $iPID = ShellExecute($SaveTo) Local $hWin = WinWaitActive($SaveTo, "") Local $Sel = MsgBox(1, "Clean Up", 'Press "Ok" to delete "' & $dump & '" and "' & $SaveTo & '" files.', 0, $hWin) If $Sel = 1 Then FileDelete($dump) FileDelete($SaveTo) EndIf If WinExists($SaveTo) Then ProcessClose($iPID) ;-----> End view "ip.txt" file ----------------- 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