Building a Smart IDE: Identifying comments

  • + 0 comments
    import re
    import sys
    
    code = sys.stdin.read()
    
    is_comment = re.compile(r"//[^\n]*|/\*.+?\*/", flags=re.DOTALL)
    
    [print(re.sub(r"\s{3,}", r"\n", comment)) for comment in is_comment.findall(code)]