<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import re

CELL_LOCATION_RE = re.compile(
    r"""
    ^
        \#
        (?:
            (?P&lt;sheet_name&gt;\w+)[.!]
            |
        )
        (?P&lt;coord&gt;[A-Za-z]+[\d]+)
    $
    """,
    re.VERBOSE)


def parse_cell_location(cell_location):
    """
    &gt;&gt;&gt; parse_cell_location("#Sheet1.C1")
    {'sheet_name': 'Sheet1', 'coord': 'C1'}
    &gt;&gt;&gt; parse_cell_location("#Sheet1!C1")
    {'sheet_name': 'Sheet1', 'coord': 'C1'}
    &gt;&gt;&gt; parse_cell_location("#C1")
    {'sheet_name': None, 'coord': 'C1'}
    """

    m = CELL_LOCATION_RE.match(cell_location)
    if not m:
        return None

    return m.groupdict()
</pre></body></html>