Zingzi Posted March 27, 2015 Share Posted March 27, 2015 (edited) Hello folks, I have stopped writing anything in Autoit for more than 4 years now and am getting back into it to do some stuff for my son's lacrosse team. Any help for this forgetful old fart would be very helpful. How do you read a line of text from a file and if it matches a set variable, copy it to a new file and repeat till end of file? For instance lets say there is a lacrosse team and each boy has a list of equipment. John Doe Helmet - CascadeR Stick - Dpole Chest - Warrior Bob Pham Helmet - STX Stick - Attack Chest - Brine etc..... I want to make a new file that shows just the sticks Stick - Dpole Stick - Attack etc... Edited March 27, 2015 by Zingzi Link to comment Share on other sites More sharing options...
SadBunny Posted March 27, 2015 Share Posted March 27, 2015 Was faster to write it than to complain about no code posted etc. #include <File.au3> _FileWriteFromArray('c:\tmp\test_output.txt', StringRegExp(FileRead('c:\tmp\test_input.txt'), "(?im)^Stick.*$", 3)) Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
kylomas Posted March 27, 2015 Share Posted March 27, 2015 Zingi, Non-SRE way... local $inFile = @scriptdir & '\lacross_team_data.txt' local $outFile = @scriptdir & '\sticks.txt' local $aData = stringsplit(fileread($inFile),@CRLF,3) for $1 = 0 to UBound($aData) - 1 if stringinstr($aData[$1],'stick') then filewrite($outfile, $aData[$1] & @CRLF) Next shellexecute($outfile) This is the input filelacross_team_data.txt 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...
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