def split_span(s):
    for match in re.finditer('\\S+', s):
        span = match.span()
yield match.group(0), span[0], span[1] - 1
How to split a string on whitespace and retain offsets and lengths of words