Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 sammy1983,Sorry for the delay - dinner got in the way. This works for me based on your posted result:#include <StringConstants.au3> #include <MsgBoxConstants.au3> $sText = "" & @CRLF & _ "" & @CRLF & _ "Verizon Wireless" & @CRLF & _ "" & @CRLF & _ "Post Office Box 660108" & @CRLF & _ "" & @CRLF & _ "Dallas, TX 75266-0108" ; Force all EOL to @CRLF $sText = StringRegExpReplace($sText, "((?<!\x0d)\x0a|\x0d(?!\x0a))", @CRLF) ; Convert double @CRLF to single $sText = StringReplace($sText, @CRLF & @CRLF, @CRLF) ; Split the last line $sText = StringRegExpReplace($sText, "(.*),\s(..)\s(\d.*)", "$1" & @CRLF & "$2" & @CRLF & "$3") ; Remove the leading @CRLF $sText = StringStripWS($sText, $STR_STRIPLEADING) MsgBox($MB_SYSTEMMODAL, "Result", "-" & @CRLF & $sText & @CRLF & "-")How does it do on teh real thing? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 I changed 1 with 0 in below code $a[0] = StringTrimRight($a[0], 0) and output is fine. Verizon Wireless However, not all the strings appear. I think loop needs review. Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 sammy1983, Sorry for the delay - dinner got in the way. This works for me based on your posted result: #include <StringConstants.au3> #include <MsgBoxConstants.au3> $sText = "" & @CRLF & _ "" & @CRLF & _ "Verizon Wireless" & @CRLF & _ "" & @CRLF & _ "Post Office Box 660108" & @CRLF & _ "" & @CRLF & _ "Dallas, TX 75266-0108" ; Force all EOL to @CRLF $sText = StringRegExpReplace($sText, "((?<!\x0d)\x0a|\x0d(?!\x0a))", @CRLF) ; Convert double @CRLF to single $sText = StringReplace($sText, @CRLF & @CRLF, @CRLF) ; Split the last line $sText = StringRegExpReplace($sText, "(.*),\s(..)\s(\d.*)", "$1" & @CRLF & "$2" & @CRLF & "$3") ; Remove the leading @CRLF $sText = StringStripWS($sText, $STR_STRIPLEADING) MsgBox($MB_SYSTEMMODAL, "Result", "-" & @CRLF & $sText & @CRLF & "-") How does it do on teh real thing? M23 But here you are assigning the address to a variable already. So will this work out? Sorry if I am asking anything wrong. Just a doubt. Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 You try it and will see. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 sammy1983,Just replace the initial assignment with this:$sText = _IEPropertyGet($oQuery3, "innertext") ; Taken from JohnOne's exampleThen it will contain the text you get from your site. If it is indeed in the format you described than the code should produce what you want. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 Wow!!!! Melba, u r nothing but amazing Genius.. That worked like charm.. Just that last 4 digits after "-" needs to be separated in next line. Otherwise, no words to say. I tried but its brain child and u need to tweek it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 sammy1983,Sorry about that - just replace this line:; Split the last line $sText = StringRegExpReplace($sText, "(.*),\s(..)\s(\d*)-(\d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4")and you should get that final split as well/ M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 sammy1983, Sorry about that - just replace this line: ; Split the last line $sText = StringRegExpReplace($sText, "(.*),\s(..)\s(\d*)-(\d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4") and you should get that final split as well/ M23 Thanks Melba. I tried and it worked. But I found another interesting thing. I didn't want to remove any of your codes but in the process of understanding how each code works, I found that using below code itself brings what I needed and the output is same. Any comments? Local $oQuery3 = _IEGetObjByName($oIE, "mailaddrbyzipcode") $sText = _IEPropertyGet($oQuery3, "innertext") $Address = StringRegExpReplace($sText, "(.*),s(..)s(d*)-(d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4") MsgBox(0,"Result", $Address) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 sammy1983, Any comments?Yes. The format of the return from the site is not as you suggested and is actually a little simpler. The code I gave you forced all EOLs into @CRLF and then reduced any double @CRLF into singles - it seems that you actually have only single @CRLF EOLs so that part was unnecessary, along with the removal of the leading blank line implied by your earlier posts. So you get the result without all the clever bits to ensure that the EOLs were standardised. No harm done - the final RegEx that you are using was the key item. I am just glad it worked after the build-up you gave me! M23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 sammy1983, Yes. The format of the return from the site is not as you suggested and is actually a little simpler. The code I gave you forced all EOLs into @CRLF and then reduced any double @CRLF into singles - it seems that you actually have only single @CRLF EOLs so that part was unnecessary, along with the removal of the leading blank line implied by your earlier posts. So you get the result without all the clever bits to ensure that the EOLs were standardised. No harm done - the final RegEx that you are using was the key item. I am just glad it worked after the build-up you gave me! M23 Honestly, no build-up. You are Genius and no denial. Thanks for everything and now I have to sit and figure out how to put each line in excel cell. Thanks a ton, again. Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 Melba, possible to break up and assign each output to variables? $Address = StringRegExpReplace($sText, "(.*),s(..)s(d*)-(d*)", "$2" & @CRLF & "$3" & @CRLF & "$4") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 8, 2014 Moderators Share Posted February 8, 2014 sammy1983,Just split the string on @CRLF:$aAddress = StringSplit(StringRegExpReplace($sText, "(.*),\s(..)\s(\d*)-(\d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4"), @CRLF, 3) ; $STR_ENTIRESPLIT (1) + $STR_NOCOUNT (2)Now you can loop through the array to get each separate part. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 Couldn't do it... ... Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 $aAddress = StringSplit(StringRegExpReplace($sText, "(.*),s(..)s(d*)-(d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4"), @CRLF, 3) For $i = 1 to $aAddress[0] MsgBox(0,"Result", $aAddress) Next Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 (edited) MsgBox(0,"Result", $aAddress) MsgBox(0,"Result", $aAddress[$i]) or ConsoleWrite( $aAddress[$i] & @CRLF) EDITL also For $i = 1 to $aAddress[0] For $i = 0 to Ubound($aAddress) -1 Edited February 8, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 I tried below code and got it in Msgbox Local $aAddress = StringSplit(StringRegExpReplace($sText, "(.*),s(..)s(d*)-(d*)", "$1" & @CRLF & "$2" & @CRLF & "$3" & @CRLF & "$4"), @CRLF) For $i = 1 to $aAddress[0] MsgBox(0,"Result", $aAddress[$i]) Next Not sure how to assign each in variable? Link to comment Share on other sites More sharing options...
sammy1983 Posted February 8, 2014 Author Share Posted February 8, 2014 MsgBox(0,"Result", $aAddress) MsgBox(0,"Result", $aAddress[$i]) or ConsoleWrite( $aAddress[$i] & @CRLF) EDITL also For $i = 1 to $aAddress[0] For $i = 0 to Ubound($aAddress) -1 Made the changes as suggested, JohnOne. Now thinking how to assign to the values to variable? Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2014 Share Posted February 8, 2014 The values are variables. They are in an array of variables. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
sammy1983 Posted February 9, 2014 Author Share Posted February 9, 2014 Completed the project successfully. Retrieved all the values in excel cells properly. Special thanks to JohnOne and Melba23. You guys are amazing!!!! Thanks a ton. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 9, 2014 Moderators Share Posted February 9, 2014 sammy1983,Glad we could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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