I have a list of strings - something like
mytext = ['This is some text','this is yet more text','This is text that contains the substring foobar123','yet more text']
I want to find the first occurrence of anything that starts with foobar. If I was grepping then I would do search for foobar*. My current solution looks like this
for i in mytext:
index = i.find("foobar")
if(index!=-1):
print i
Which works just fine but I am wondering if there is a 'better' (i.e more pythonic) way of doing this?
Cheers, Mike