def accept_re(regexp, buf, pos):
    """Accept a regular expression at the current buffer position."""
    match = regexp.match(buf, pos)
    if not match:
        return None, pos
    return buf[match.start(1):match.end(1)], match.end(0)
