jack87 Posted December 22, 2009 Share Posted December 22, 2009 Hi guys, i'm new on this forum and on autoit. I need as soon as possible a program to extract emails, faxes and html websites from .txt files. i have thousands of these info:(examples) company 1 adress 1xx continue adress 1xx Phone 1xxx Fax 1xxxx email 1xxxx http 1xxxx company 2 adress 2xx continue adress 2xx Phone 2xxx Fax 2xxxx email 2xxxx http 2xxxx so what strings should i create to extract the files and collect them on a new .txt file? any help will be very useful thanks! Link to comment Share on other sites More sharing options...
SEuBo Posted December 22, 2009 Share Posted December 22, 2009 #include <File.au3> Global $aRet[1], $email = StringRegExp(FileRead(@DesktopDir&"\company.txt"),"(?<=email\s)([\w\d\.\-]+\@[\w\d\-]+(\.\w+){1,2})",3) ReDim $aRet[Floor(UBound($email)-1 /2)] For $i = 0 to UBound($email)-1 Step 2 $aRet[$i/2] = $email[$i] Next _FileWriteFromArray(@DesktopDir&"\companyemails.txt",$aRet) ShellExecute(@DesktopDir&"\companyemails.txt") AutoIt Examples/UDF's:Generate Function at Runtime using IRunningObjectTable / AutoItObjectVery Simple Inter-Process Communication (using AutoItObject Pure AutoIt) Link to comment Share on other sites More sharing options...
jack87 Posted December 22, 2009 Author Share Posted December 22, 2009 thank you SEuBo, in which line i have to insert the .txt file i want to get the emails from? Link to comment Share on other sites More sharing options...
SEuBo Posted December 22, 2009 Share Posted December 22, 2009 thank you SEuBo, in which line i have to insert the .txt file i want to get the emails from? First Line "FileRead(@DesktopDir&"\company.txt")". Just replace that with "FileRead([yourfilepath])" AutoIt Examples/UDF's:Generate Function at Runtime using IRunningObjectTable / AutoItObjectVery Simple Inter-Process Communication (using AutoItObject Pure AutoIt) Link to comment Share on other sites More sharing options...
jack87 Posted December 22, 2009 Author Share Posted December 22, 2009 it gives array error on this part ReDim $aRet[Floor(UBound($email)-1 /2)] For $i = 0 to UBound($email)-1 Step 2 $aRet[$i/2] = $email[$i] what can i change? Link to comment Share on other sites More sharing options...
picea892 Posted December 22, 2009 Share Posted December 22, 2009 I would suggest that you change your text file to a ini format then you can use the iniread, inireadsection etc. Much easier and more powerful than your other option of fileread. I also would suggest that you do not understand the purpose of this forum. Most people do not take well to scripting demands with as soon as possible tagged to it. The expectation is that you have at least tried to solve the problem and have code to present instead of "so what strings should i create to extract the files". You will get a much better response if you adhere to this. Picea892 Link to comment Share on other sites More sharing options...
SEuBo Posted December 23, 2009 Share Posted December 23, 2009 it gives array error on this part ReDim $aRet[Floor(UBound($email)-1 /2)] For $i = 0 to UBound($email)-1 Step 2 $aRet[$i/2] = $email[$i] what can i change? Try to replace it with: For $i = 0 to UBound($email)-1 Step 2 _ArrayAdd($aRet,$email[$i]) Next (erase the ReDim [...] too) Now you also need #include <Array.au3> This should be a bit slower, but that should not fail at all. (Didnt test it.) AutoIt Examples/UDF's:Generate Function at Runtime using IRunningObjectTable / AutoItObjectVery Simple Inter-Process Communication (using AutoItObject Pure AutoIt) 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