zocker30 Posted August 3, 2012 Posted August 3, 2012 (edited) Hey =) i need some help. My problem/what i want: A program that checks every line's ending for ".php" and if it ends with ".php" the program writes the line to a second text file. Example: I have a textfile with this inside: www.google.com www.google.com/index.php www.youtube.com www.youtube.com/login.php Now i run the autoit program , and it check everyline for the ending ".php". Now it writes every of those lines to a text document and it will look like this: www.google.com/index.php www.youtube.com/login.php Thats what it should do... Anyone know how to make such a program? Thanks in advance & best regards Edited August 3, 2012 by zocker30
Xenobiologist Posted August 3, 2012 Posted August 3, 2012 $re = StringRegExp(ClipGet(), '(.*.+php)', 3) For $i = 0 to UBound($re) -1 ConsoleWrite($re[$i] & @LF) Next Try this when you have somthing in your Clipboard. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
saywell Posted August 3, 2012 Posted August 3, 2012 Or use _FileReadToArray and step through the array checking for those that end in .php. Stringright would be useful here. You can then write the matching ones to your new file. William
somdcomputerguy Posted August 3, 2012 Posted August 3, 2012 (edited) These three functions could be used. This is just a slightly different (and much more basic) way than the snips already provided of accomplishing your objective.FileReadLineStringRightFileWriteLine Edited August 3, 2012 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
GEOSoft Posted August 3, 2012 Posted August 3, 2012 (edited) Local $a_PHP = StringRegExp(FileRead("C:PathSomefile.txt"), "(?m:^)(.*.php)(?:v|$)+", 3) If NOT @Error Then $hFile = FileOpen(@DesktopDir & "results.txt", 2) $s_Txt = "" For $i = 0 To Ubound($a_PHP) -1 $s_Txt &= $a_PHP[$i] & @CRLF Next FileWrite($hFile,StringStripWS( $s_Txt, 2)) FileClose($hFile) EndIf Edit: Forgot to add the @CRLF and then strip the last one for the write. Edited August 3, 2012 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
zocker30 Posted August 4, 2012 Author Posted August 4, 2012 Thanks to everyone posting! Ill try all of this now !
zocker30 Posted August 4, 2012 Author Posted August 4, 2012 Local $a_PHP = StringRegExp(FileRead("C:PathSomefile.txt"), "(?m:^)(.*.php)(?:v|$)+", 3) If NOT @Error Then $hFile = FileOpen(@DesktopDir & "results.txt", 2) $s_Txt = "" For $i = 0 To Ubound($a_PHP) -1 $s_Txt &= $a_PHP[$i] & @CRLF Next FileWrite($hFile,StringStripWS( $s_Txt, 2)) FileClose($hFile) EndIf Edit: Forgot to add the @CRLF and then strip the last one for the write. Works perfect ! Thanks alot :DDD
GEOSoft Posted August 4, 2012 Posted August 4, 2012 Glad it helped. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
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