jdelaney Posted February 15, 2013 Share Posted February 15, 2013 I'm using StringRegExp, with Flag = 4: Return an array of arrays containing global matches including the full match (Perl / PHP style). example: #include <Array.au3> $string = "asdf qwer zxcv" & @CRLF & "1231 4564 7897" & @CRLF & "poui lkjh mnbv" $array = StringRegExp($string, "(?U)(\w{4,4})\s(\w{4,4})\s(\w{4,4})\s?", 4) ; only way I know how: temp arrays For $i = 0 To UBound($array)-1 $tempArray = $array[$i] For $j = 1 To UBound($tempArray)-1 ConsoleWrite("[i,j]:[" & $i & "," & $j & "] [value]:[" & $tempArray[$j] & "]" & @CRLF) Next Next Is there anyway to work with within the array without setting it to the $tempArray? Conceptually, something like: For $i = 0 To UBound($array)-1 For $j = 0 To UBound($array[$i])-1 ConsoleWrite($array[$i].[$j]) Next Next IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 15, 2013 Moderators Share Posted February 15, 2013 jdelaney, As far as I remember from previous discussions about this you have to extract the inner array from the outer array to access it. AutoIt does not know what is in each array element and so there is no programmatic way to access it directly. 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...
Moderators Melba23 Posted February 15, 2013 Moderators Share Posted February 15, 2013 jdelaney, You could use a wrapper function along these lines: #include <Array.au3> $sString = "Here is a string which we will split" Global $aArray[2] = [$sString, StringSplit($sString, " ")] _Extract_Inner_Index($aArray[1], 2) _ArraySort($aArray[1], 0, 1) _Extract_Inner_Index($aArray[1], 2) Func _Extract_Inner_Index(ByRef $avInput, $iIndex) MsgBox(64, "_Extract_Inner_Index", "Index [" & $iIndex & "] = " & $avInput[$iIndex]) EndFunc It needs a lot of errorchecking code added and is not exactly elegant, but it is better than nothing. 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...
JohnOne Posted February 15, 2013 Share Posted February 15, 2013 Without temp array, but using a func #include <Array.au3> $string = "asdf qwer zxcv" & @CRLF & "1231 4564 7897" & @CRLF & "poui lkjh mnbv" $array = StringRegExp($string, "(?U)(\w{4,4})\s(\w{4,4})\s(\w{4,4})\s?", 4) ; only way I know how: temp arrays For $i = 0 To UBound($array) - 1 _Parse($array[$i]) Next Func _Parse(ByRef $array) For $j = 1 To UBound($array) - 1 ConsoleWrite("[i,j]:[" & $i & "," & $j & "] [value]:[" & $array[$j] & "]" & @CRLF) Next EndFunc ;==>_Parse 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...
Malkey Posted February 16, 2013 Share Posted February 16, 2013 Same method as M23, but without the _ArraySort(). Local $string = "asdf qwer zxcv" & @CRLF & "1231 4564 7897" & @CRLF & "poui lkjh mnbv" Local $array = StringRegExp($string, "(?U)(\w{4,4})\s(\w{4,4})\s(\w{4,4})\s?", 4) Local $sDisplayArrays For $i = 0 To UBound($array) - 1 For $j = 0 To UBound($array[$i]) - 1 $sDisplayArrays &= "array[" & $i & "], index[" & $j & "] =" & @TAB & _ArrayValue($array[$i], $j) & @LF Next Next MsgBox(0, "Arrays Displayed", $sDisplayArrays) Func _ArrayValue(ByRef $array, $iIndex) Return $array[$iIndex] EndFunc ;==>_ArrayValue I really think it is easier to find a required regular expression pattern using flag 3 and returning one array of global matches than using flag 4 and entering the added complexity of dealing with arrays in an array. Local $string = "asdf qwer zxcv" & @CRLF & "1231 4564 7897" & @CRLF & "poui lkjh mnbv" Local $aArray = StringRegExp($string, "\w+\b", 3) __ArrayDisplay($aArray) ; ------- Display Array -------- Func __ArrayDisplay(ByRef $array) Local $sArrayDisplay = "Row" & @TAB & "Col 0" & @CRLF & "------------------------" & @CRLF For $i = 0 To UBound($array) - 1 $sArrayDisplay &= " [" & $i & "]" & @TAB & $array[$i] & @CRLF Next MsgBox(0, "ArrayDisplay", $sArrayDisplay) EndFunc ;==>__ArrayDisplay 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