Jump to content

_ArrayFindAll help needed


Go to solution Solved by ioa747,

Recommended Posts

I'm using arrayfindall, but if there is a different way let me know.

I have a column that I need to find all the numbers of a certain value. In general it works fine, but there are situations where I might have two values in a cell within that column. I need to evaluate each of those numbers as separate entities. Those values are separated by a "|". The problem is I can't use the partial search parameter value in arrayfindall because it may pick up the "10" in the value of "110" and I don't want that. I'm thinking I have to use the regexp parameter inside the arrayfindall, but I don't know how to do that. I guess All numbers can be encapsulated in "|" like "|23|54|" (which I don't know how to do either), but I just don't want to be bothered with the encapsulating situation because I would need that...I'm assuming...when there is just one value in the cell as well, I don't want to have to do "|34|". Any help? Thanks.

Edited by Champak
Link to comment
Share on other sites

  • Solution
Posted (edited)

RegExpQuickTester 2.5p  will help

#include <Array.au3>


Local $aArray[5][5] = [[0, 1, 2, 1, 0], _
        [125, "5|12", 5, 4, 2], _
        ["4|12", 122, 3, "1|12", 3], _
        [0, 3, "2|13", 1, 0], _
        [12, 5, 5, 4, 1]]
;~ _ArrayDisplay($aArray, "2D array")

Local $aResult = _ArrayFindAll($aArray, "\b12\b", Default, Default, Default, 3, 0)
_ArrayDisplay($aResult, "Found in Column 0")

$aResult = _ArrayFindAll($aArray, "\b12\b", Default, Default, Default, 3, 2, True)
_ArrayDisplay($aResult, "Found in Row 2")

Tip:
a small sample of your array would help so we don't have to imagine or write about it

 

Edit:

from  12(?:\d*)  to  \b12\b
because 12(?:\d*)  would also catch  121

Edited by ioa747
corection

I know that I know nothing

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...