The methods presented below can be used to find specific items or keywords in a list. If you want to filter a list with certain patterns or criteria, have a look at the how-to Filter lists.
Find (identical) items in a list (Item Index)
The component Item IndexInputs List (L) List to search Item (i) Item to search for Outputs Index (i) The index of item in the list, or -1 if the item could not be found.
The item to be searched for in a list, must be identical to the one that is
provided as input. Every element in Grasshopper will get a unique ID, even if
strings with equal content. Item IndexInputs List (L) List to search Item (i) Item to search for Outputs Index (i) The index of item in the list, or -1 if the item could not be found.
Find equal items in a list (Member Index)
The component Member IndexInputs Set (S) Set to operate on. Member (M) Member to search for. Outputs Index (I) Indices of member. Count (N) Number of occurences of the member.
At output I we get the indices of the matches and at output N the number of occurrences for each member in the set.
Find similar items in a list (Find similar member)
The component Find similar memberInputs Data (D) Data to search for. Set (S) Set to search. Outputs Hit (H) Member in S closest to D. Index (i) Index of H in set.
Text-based search (Match Text)
The component Match TextInputs Text (T) Text to match Pattern (P) Optional wildcard pattern for matching RegEx (R) Optional RegEx pattern for matching Case (C) Compare using case-sensitive matching Outputs Match (M) True if the text adheres to all supplied patterns
As an alternative to a pattern at P, we can also use a regular expression.
A list of presumably supported expressions can be found
here.
For example, we can use ^.e
to find text that has an e as second character.
This component will identify if a string matches a pattern and can not be used
to extract a substring based on this pattern (like Regular Expression Capture
Group does). This can be accomplished by implementing custom C# code, as shown
in this how-to
Find data in corresponding lists (Key/Value Search)
The component Key/Value SearchInputs Keys (K) A list of key values. Values (V) A list of value data, one for each key. Search (S) A key value to search for Outputs Result (R) Resulting item in the value list that matches the Search key
To search the other way around, especially if we don’t know the exact values of
the linked data, a query with logical operatorsInputs List (L) List to filter Dispatch pattern (P) Dispatch pattern Outputs List A (A) Dispatch target for True values List B (B) Dispatch target for False values
Find geometrically identical objects
There is no ease way to find geometrically identical objects, which are equal or congruent. But, we can tweak the method describes for removing duplicate curves to search for matching criteria of geometric objects.