import re


def count_characters(text, whites=False):
    """
    Get character count of a text

    Args:
        whites: If True, whitespaces are not counted
    """
    if whites:
        return len(text)
    else:
        return len(re.sub(r"\s", "", text))