from typing import Tuple
import re


def _match_line_offset(m: 're.Match') -> Tuple[int, int, str]:
    """ Convert a match position into a lineno, offset, and line """
    pos = m.span()[0]
    lines = m.string.split('\n')
    for line_i, line in enumerate(lines, 1):
        new_pos = pos - len(line) - 1
        if new_pos < 0:
            return line_i, pos + 1, line
        pos = new_pos
    assert False