def _split_dimension(text):
    """
    Returns the number and unit from the given piece of text as a pair.

    >>> _split_dimension('1pt')
    (1, 'pt')
    >>> _split_dimension('1 pt')
    (1, 'pt')
    >>> _split_dimension('1  \tpt')
    (1, 'pt')
    >>> _split_dimension('1  \tpt  ')
    (1, 'pt')
    >>> _split_dimension(' 1  \tpt  ')
    (1, 'pt')
    >>> _split_dimension('3')
    (3, None)
    >>> _split_dimension('-12.43mm')
    (-12.43, 'mm')
    >>> _split_dimension('-12.43"')
    (-12.43, '"')
    """
    match = _dimension_finder.match(text)
    if not match:
        raise DimensionError("Can't parse dimension '%s'." % text)
    number = match.group(1)
    unit = match.group(4)
    if '.' in number:
        return (float(number), unit)
    else:
        return (int(number), unit)