UEZ Posted October 6, 2012 Posted October 6, 2012 (edited) Another example. Local $string = "Ali Omar Sheariff, 31, of a fake address, continued." & @CRLF & _ "de la Harpe Mean Francois, Miscellaneous writer." & @CRLF & _ "de Looze Henk, 33, a Dutch guy." & @CRLF & _ "Ballard Liz Anne Marie, 60, of another fake address" & @CRLF & _ "La Blanc Sean P, 46, homeless." & @CRLF & _ "Le Barbier Jean Jacques-Francois, 30, 6 ft under." & @CRLF & _ "van der Zande Jos, 22, no intro needed." & @CRLF & _ "McMillen Sir Barry E, 52, of another address, continued." ConsoleWrite(StringRegExpReplace($string, "(?i)(v?a?n? ?d?(?:a|e)?r? ?l?(?:a|e)? ?S+)h(.+?),(.+)", "2 1,3") & @LF) #cs Returns:- Omar Sheariff Ali, 31, of a fake address, continued. Mean Francois de la Harpe, Miscellaneous writer. Henk de Looze, 33, a Dutch guy. Liz Anne Marie Ballard, 60, of another fake address Sean P La Blanc, 46, homeless. Jean Jacques-Francois Le Barbier, 30, 6 ft under. Jos van der Zande, 22, no intro needed. Sir Barry E McMillen, 52, of another address, continued. #ce I got the original text file and your regex solution doesn't work for some of them (also my solution above): Local $string = "Ali Omar Sheariff, 31, of a fake address, continued." & @CRLF & _ "de la Harpe Mean Francois, Miscellaneous writer." & @CRLF & _ "de Looze Henk, 33, a Dutch guy." & @CRLF & _ "Ballard Liz Anne Marie, 60, of another fake address" & @CRLF & _ "La Blanc Sean P, 46, homeless." & @CRLF & _ "Le Barbier Jean Jacques-Francois, 30, 6 ft under." & @CRLF & _ "van der Zande Jos, 22, no intro needed." & @CRLF & _ "Primous Louis Jr K, 53, of 1571 Mound St, theft, dismissed, domestic violence, dismissed." & @CRLF & _ "Jackson Darryl Jr Anthony, 23, of 918 Clifton Ave, violation of tpo, bench warrant ordered." & @CRLF & _ "Judge Trempe E. Thomas." & @CRLF & _ "McMillen Sir Barry E, 52, of another address, continued." ConsoleWrite(StringRegExpReplace($string, "(?i)(v?a?n? ?d?(?:a|e)?r? ?l?(?:a|e)? ?S+)h(.+?),(.+)", "2 1,3") & @LF) Anyhow, I like your regex solutions! Br, UEZ Edited October 6, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
polingkyle Posted October 9, 2012 Author Posted October 9, 2012 (edited) I think I have it doing what it needs to do now. expandcollapse popup#include <file.au3> #Include <string.au3> #include <array.au3> Local $username = EnvGet("USERNAME") Local $userprofile = EnvGet("USERPROFILE") $TextFileName = $userprofile & "DesktopMuniCourtData.txt" WinActivate ("MuniCourtData") Send("^s") WinClose ("MuniCourtData") Local $LineCount = _FileCountLines($TextFileName) ;fixes midline returns $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, @CR,"#") FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, @CRLF,"#") FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, @LF,"") FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 Dim $i Do $i += 1 $FileContents = FileRead($TextFileName) $Name = _StringBetween($FileContents, '#', ',') If @error Then Exit $FullName = _StringProper(StringRegExpReplace($Name[0], '#', '')) $Lastname = _StringBetween($FullName, '', ' ') $Firstname = _StringBetween($FullName, ' ', '') $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, $Lastname[0] & " " & $Firstname[0], $Firstname[0] & " " & $Lastname[0]) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, "#" & $Firstname[0], @CRLF & $Firstname[0]) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, ":##", ":",1) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 $FileContents = FileRead($TextFileName) $FileContents = StringReplace($FileContents, "##", @CRLF) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) $FileContents = 0 ;Reset variables $Name = 0 $FullName = 0 $Firstname = 0 $Lastname = 0 $FileContents = 0 Until $i = $LineCount ;Launches the updated file ShellExecute ($userprofile & "DesktopMuniCourtData.txt") WinActivate ("MuniCourtData") The only thing I can't figure out is why it won't launch the file after the loop exits. It will launch it sometimes but not others. The log shows a clean exit but it just won't open the document after the loop: >Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:MuniCourt.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop +>18:20:37 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 3.023 Edited October 9, 2012 by polingkyle
Spiff59 Posted October 9, 2012 Posted October 9, 2012 (edited) Your hard drive hasn't long to live Edit: And on a more constructive note, your hard drive is likely still busy executing one of the multitude of file reads, writes, and deletes in your script. If you're intent on this mega-I/O-intensive approach, you'll likely need to insert a Sleep() prior to your ShellExecute() to give your hard drive a chance to catch up to your script. Start at Sleep(100) and bump it up by 100 until you get a consistant success rate. Edited October 10, 2012 by Spiff59
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