def get_text(original, token, replace):
    """Convenience function for getting the text to use for a match when
    formatting.
    If ``replace`` is False, returns the part of ``original`` between
    ``token.startchar`` and ``token.endchar``. If ``replace`` is True, returns
    ``token.text``.
    """
    if replace:
        return token.text
    else:
        return original[token.startchar:token.endchar]
