import re


def error_038_italic_tag(text):
    """Fix the error and return (new_text, replacements_count) tuple."""
    backup = text
    (text, count) = re.subn(r"<(i|em)>([^\n<>]+)</\1>", "''\\2''", text, flags=re.I)
    if re.search(r"</?(?:i|em)>", text, flags=re.I):
        return (backup, 0)
    else:
        return (text, count)