Forum Discussion

RUDOLF_BOTHMA's avatar
RUDOLF_BOTHMA
Community Hero
6 years ago
Solved

Use .Find to get all elements that do NOT match the search properties

Hi all,   I'm trying to find a way to make my code less loopy and possibly improve the performance.  I'm trying to take a list of items, get rid of the items that I'm not interested in, and keep ...
  • AlexKaras's avatar
    6 years ago

    Hi,

     

    The below may appear to be not relevant for your real case because I don't know how color is determined, but as an idea you may consider using regular expressions for search parameters.

    Sample pseudocode:

    var objects = root.FindAllChildren(['Type', 'Color'], ['regexp: (vegetable)|(fruit)', 'regexp:^(red)'], depth);

     

  • RUDOLF_BOTHMA's avatar
    RUDOLF_BOTHMA
    6 years ago

    That is SOO exactly what I was looking for, thanks ! :smileyvery-happy:

    Syntax correction:

    It's 'regexp:[^(red)]' - it was just missing the [] around the ^(red)