首页 > 技术文章 > HackerRank - "Building a Smart IDE: Identifying comments"

tonix 2015-06-03 07:34 原文

import re

import io
import sys
input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='utf-8')

s = input_stream.readlines()
s = "\n".join(s)

pc = '(//.*|/\*[\d\D]*?\*/)'
mc = re.findall(pc, s)
for v in mc:
    vs = v.split("\n\n")
    for l in vs:
        print (l.lstrip())

推荐阅读