import re


def slurp_word(s, idx):
    """Returns index boundaries of word adjacent to `idx` in `s`."""
    alnum = r"[A-Za-z0-9_]"
    start, end = idx, idx

    while True:
        if re.match(alnum, s[start - 1]):
            start -= 1
        else:
            break
    end = idx
    while True:
        if re.match(alnum, s[end]):
            end += 1
        else:
            break

    return start, end