def replace_comments(text, *, replace_char=' '):
    """Remove (potentially nested) multiline comments from `text`"""
    result = []
    in_comment = 0
    skip = 0
    OPEN_COMMENT = '(', '*'
    CLOSE_COMMENT = '*', ')'
    for c, next_c in zip(text, text[1:] + ' '):
        if skip:
            skip -= 1
            result.append(replace_char)
            continue
        pair = c, next_c
        if pair == OPEN_COMMENT:
            in_comment += 1
            skip = 1
            c = replace_char
        elif pair == CLOSE_COMMENT:
            in_comment -= 1
            skip = 1
            c = replace_char
        if in_comment > 0:
            result.append(replace_char)
        else:
            result.append(c)
    return ''.join(result)
