python - Searching string for different substrings -


i have string. need know if of following substrings appear in string.

so, if have:

thing_name = "visa assessments" 

i've been doing searches with:

any((_ in thing_name _ in ['assessments','kilobyte','international'])) 

i'm going through long list of thing_name items, , don't need filter, exactly, check number of substrings.

is best way this? feels wrong, can't think of more efficient way pull off.

you can try re.search see if faster. along lines of

import re pattern = re.compile('|'.join(['assessments','kilobyte','international'])) ismatch = (pattern.search(thing_name) != none) 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -