<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace_emoticons(content, excluded_markups):
 """ Replace the emoticons string by HTML images. If some markups should be excluded from replacement, BeautifulSoup will be used. """

    if not excluded_markups:
        return regexp_replace_emoticons(content)

    excluded_markups = excluded_markups.split(',') + ['[document]']
    soup = BeautifulSoup(content, 'html.parser')

    for content_string in list(soup.strings):
        if content_string.parent.name not in excluded_markups:
            replaced_content_string = regexp_replace_emoticons(content_string)
            if content_string != replaced_content_string:
                content_string.replace_with(
                    BeautifulSoup(replaced_content_string, 'html.parser'))
    return str(soup)