#!/usr/bin/env python3
"""
Contains functions for analyzing text.
"""

import re

def count_spaces(text):
    """
    Counts the number of spaces in supplied text.
    """
    return len(re.sub('[^ ]', '', text))

def count_letters(text):
    """
    Counts the number of letters (a-zA-Z) in supplied text.
    """
    return len(re.sub('[^a-zA-Z]', '', text))

def count_special(text):
    """
    Counts the number of special characters ((),".:-'?) in supplied text.
    """
    specials = '(),".:-\'?'
    result = 0
    for letter in text:
        if letter in specials:
            result += 1
    return result

def paragraph_max_specials(text):
    """
    Gets the number of special chars in the paragraph with the most specials.
    """
    result = 0
    for line in text.split('\n'):
        length = len(line)
        if length == 0:
            continue
        specials = count_special(line)
        if result < specials:
            result = specials
    return result
