def split_first(s, delims):
min_idx = None<EOL>min_delim = None<EOL>for d in delims:<EOL><INDENT>idx = s.find(d)<EOL>if idx < <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>if min_idx is None or idx < min_idx:<EOL><INDENT>min_idx = idx<EOL>min_delim = d<EOL><DEDENT><DEDENT>if min_idx is None or min_idx < <NUM_LIT:0>:<EOL><INDENT>return s, '<STR_LIT>', None<EOL><DEDENT>return s[:min_idx], s[min_idx+<NUM_LIT:1>:], min_delim<EOL>
Given a string and an iterable of delimiters, split on the first found
delimiter. Return two split parts and the matched delimiter.

If not found, then the first part is the full input string.

Example::

    >>> split_first('foo/bar?baz', '?/=')
    ('foo', 'bar?baz', '/')
    >>> split_first('foo/bar?baz', '123')
    ('foo/bar?baz', '', None)

Scales linearly with number of delims. Not ideal for large number of delims.