Skip to content
Advertisement

Filter down list of elements by comparing their name properties to a list of potential partial matches

I’m working in python and Revit, and I have a list of detail items with a name parameter. I’d like to filter my list down just the detail items where the name contains a partial match for any string in a list of partial matches. I have a working solution, but my intuition is telling me there ought to be a way to simplify it, since it doesn’t feel very readable to me.

This works:

JavaScript
JavaScript

This doesn’t:

JavaScript

Advertisement

Answer

Per comments from Jeremy and Barmar, here is the final solution I used:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement