import re


def surrounding_word(s: str, index: int, with_line_end=False):
    """Find the start and end index of the word around the current index.

    :param s String in which we seek word
    :param index Current index within the string, identifying a position within the sought word
    :param with_line_end If set, a trailing line end character will be included with the word

    Returns: (start, end) of word identified by 'index' or None if index is not a position in a word."""
    is_word = re.compile(r'\w')
    #print(f' s=[{s}], index={index}')
    if index >= len(s):
        index = len(s) - 1

    if is_word.match(s[index]) is None:
        return None
    else:
        start = index
        end = index
        # 'start' is inclusive, that is, index of part of the word
        while start - 1 > 0 and is_word.match(s[start - 1]):
            start -= 1
        # 'end' is exclusive, that is, its index is NOT part of the word
        while end < len(s) and (is_word.match(s[end]) or (with_line_end and s[end] in ['.', '?', '!'])):
            end += 1
        return start, end