Monday, 19 August 2013

Searching string for different substrings

Searching string for different substrings

I have a string. I need to know if any of the following substrings appear
in the string.
So, if I have:
thing_name = "VISA ASSESSMENTS"
I've been doing my searches with:
any((_ in thing_name for _ in ['ASSESSMENTS','KILOBYTE','INTERNATIONAL]))
I'm going through a long list of thing_name items, and I don't need to
filter, exactly, just check for any number of substrings.
Is this the best way to do this? It feels wrong, but I can't think of a
more efficient way to pull this off.

No comments:

Post a Comment