On Jul 18, 2:11 am, Eloff wrote:
> Almost every time I've had to do parsing of text over the last 5 years
> I've needed this function:
[snip]
> It finds the first matching substring in the target string, if there
> is more than one match, it returns the position of the match that
> occurs at the l
Eloff wrote:
> Almost every time I've had to do parsing of text over the last 5 years
> I've needed this function:
>
> def find_first(s, subs, start=None, end=None):
> results = [s.find(sub, start, end) for sub in subs]
> results = [r for r in results if r != -1]
> if results:
>