soup = BeautifulSoup(html, 'html.parser')
comments = soup.findAll(text=lambda text: isinstance(text, Comment) and 
    text.find('if') != -1)
[comment.extract() for comment in comments]
Regex to remove conditional comments